"Show If" questions in a save file template

Hi everyone,

Im struggling how to describe my problem so i do aplogise in advance if i make zero sense,

Im trying to save a pdf file with the results of questionnaire i have in my app.

How would i best achieve selecting questions and answers that will generate in the pdf file i create. Im trying to avoid having a list of 20 questions that are not relevant because of the show if functions in my questionnaire.

The questionnaire is a medical assessment, so it starts with roughly 30 questions. Within the assessment i have an area of body pain which i reference to another table as multiple area of body pains can be selected with multiple different questions. Its this section i am struggling on how to pull select questions into the pdf file. The leg will have 4 questions that are different to 4 questions relating to the neck.

I dont want to have all the body part questions pre filled on the report if only leg and neck are selected.

I hope that makes a little sense.

Regards
Ben

Hello @Ben_Rix, your problem can be solved using templates if expressions, the idea of those is that you build your template listing ALL of the sections it could possibly have (in your case if someone feels pain in every part of the body haha), and then use conditional expressions that would return TRUE if you’d like that section to be shown in your pdf file, or FALSE if you want that entire section to be skipped.

1 Like

Thanks Rafael,

This could be exactly what I’m looking for.

Regards
Ben

2 Likes

Hi Rafael,

I believe this is something i am looking for:

<<If: COUNT([Related OrderDetails])>0>>

Order Detail Records

<<Start: [Related OrderDetails]>>

Product: <<[Product]>>
Qty: <<[Qty]>>
Amount: <<[Amount]>>

<<End>>

<<EndIf>>

How would i use the if statement on Related order details (in my case related area of pain) Body pain = Neck)

Regards
Ben

1 Like

Hey Ben, for building the template itself i’d need to know more about your app structure, particularly regarding how you ask the user the questions and how are their answers stored.

The general idea that i have is that you divide your template in sections per body part and then use as an if condition a COUNT(SELECT()) expression that would check if there is at least an entry on a given body part, and if there isn’t, the section shouldn’t be displayed.

2 Likes

@Rafael_ANEIC-PY has helped massively on this one as ive been struggling all weekend on how to achieve this. I just wanted to put the solution on here so others could see if they ever needed anything similar. Ive still got so much to learn, but i feel like im getting there bit by bit with all the help from app sheet community.

Hey Ben, i believe what you’re looking for is:

<<IF: COUNT(SELECT(Area of Pain[Area of Pain],AND([Document ID]=[_THISROW].[Document ID],[Area of Pain]="Neck")))>0>>

Neck

Flexion ROM: <<INDEX(SELECT(Area of Pain[Flexion ROM:],[Document ID]=[_THISROW].[Document ID]),1)>>
Extension ROM: <<INDEX(SELECT(Area of Pain[Extension ROM:],[Document ID]=[_THISROW].[Document ID]),1)>>


<<EndIf>>

That’s the pattern i believe you should repeat for each bodypart, let me know if you have any questions.

2 Likes

Thanks Steve :wink:

1 Like