Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Problems with conditional logic

  • dralistair
  • dralistair's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 1 month ago #193796 by dralistair
Problems with conditional logic was created by dralistair
I have an assessment tool that uses two Array(F) questions.

One collects symptom data and has 47 questions. Uses a four-point answer option (0,1,2,3)

One collects performance data and has 8 questions. Uses a five-point answer option (1,2,3,4,5)

I have written summary equations that add up the number of symptoms for different subgroups within the 47 questions.

This works well and I can get a count of the number of symptoms for each subgroup which are endorsed at greater than or equal to (ge) 2 on the answeroptions. I can also get a count of the number of performance items that are rated (ge) 4 on the performance answeroptions.

The problem comes when I try to apply conditional logic to determining whether the combination of symptom count and performance count is sufficient to suggest a diagnosis.

The rules are pretty straightforward. e.g. for Inattentive ADD a possible diagnosis would be indicated by a symptom count (InnADDcount) (ge) 6 AND a performance count (PERFcount) ge 1.

I have made a Diagnostic Summary question of Equation type.

In the text box (not the equation box) I have put the following;
Code:
Diagnostic Likelihood Summary
 
 Inattentive ADD: {if(InnADDcount ge 6 and  PERFcount ge 1, 'YES', 'NO')}
 
     Hyperactive ADD: {if(HypADDcount ge 6 and PERFcount ge 1, 'YES','NO')}
 
     Combined ADHD: {ADHDcomb}
 
                          ODD: {if(ODDcount ge 8 and PERFcount ge 1, 'YES','NO')}
 
   Conduct Disorder: {if(CDcount ge 3 and PERFcount ge 1, 'YES','NO')}
 
Anxiety/Depression: {if(ANXDEPcount ge 7 and PERFcount ge 1, 'YES','NO')}

And this doesn't work.

It seems to process the logic OK. There are no warnings or indications that the syntax is wrong.

But, each summary evaluates to NO no matter what the count numbers are in symptoms and performance.

I am attaching the lss file for this survey.

The questions I have are;

(a) Is it reasonable to structure an equation question in this way, i.e. putting multiple equations mixed with header text into the one evaluation space? and, if so;
(b) is there something wrong with the conditional logic that I am using.

It seems pretty simple to me and I just can't see where I am going wrong.

p.s. I have experimented by just using one equation question for each diagnostic check and get the same result

Thanks for having a look. Your advice would be very welcome.

File Attachment:

File Name: vanderbilt.lss
File Size:107 KB
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #193800 by DenisChenu
Replied by DenisChenu on topic Problems with conditional logic
Unsure because didn't test but 90% chance it fix the issue : add .NAOK to the variables

manual.limesurvey.org/Expression_Manager#Usage_of_NAOK

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • dralistair
  • dralistair's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 1 month ago #193807 by dralistair
Replied by dralistair on topic Problems with conditional logic
I added NAOK to all of the variables in the Diagnostic summary.

It made no difference. Continues to evaluate everything to NO.

I tried adding .value and .valueNAOK.

Again no difference. The conditions continue to evaluate to NO regardless of the number of counts.

Thanks for the idea, though.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #193810 by DenisChenu
Replied by DenisChenu on topic Problems with conditional logic
Check your survey logic : seems you have & nbsp inside the equation.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago - 4 years 1 month ago #193811 by Joffm
Replied by Joffm on topic Problems with conditional logic
Hi,

Remove the text inside your equations
and there is a " " inside your first if-statement of your summary.
Diagnostic Likelihood Summary</u></span></p><p><strong>&nbsp;Inattentive ADD</strong>: {if(InnADDcount ge 6 and &nbsp;PERFcount ge 1, 'YES', 'NO')}


And you have to use "NAOK".
Reason: Your questions are not mandatory, and you calculate a "sum". Without NAOK the sum will not be calculated if one of the questions is not answered.

Joffm

This I get setting everything to "very often" and "poroblematic"



Problem:
In ADHDComp you have the equation
<p>{if(InnADDcount ge 6 and HypADDcount ge 6 and PERFcount ge 1, 'YES','NO')}</p>
BUT PERFCount is not calculated yet.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 1 month ago by Joffm.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • dralistair
  • dralistair's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 1 month ago #193837 by dralistair
Replied by dralistair on topic Problems with conditional logic
Thanks for that.

I had the answers as non-mandatory to make for quicker testing. So, I was just exploring the InnADD to start with. When it is deployed I will have both questions set to mandatory. I have reset both questions back to mandatory.

I went through and removed the "&nbsp;" from the first statement.

I also put in the NAOK.

The Summary equation now looks like this;
Code:
p><span class="text-big"><u>Diagnostic Likelihood Summary</u></span></p><p><strong>Inattentive ADD</strong>: {if(InnADDcount.NAOK ge 6 and PERFcount.NAOK ge 1, 'YES', 'NO')}</p><p><strong>Hyperactive ADD</strong>: {if(HypADDcount.NAOK ge 6 and PERFcount.NAOK ge 1, 'YES','NO')}</p><p><strong>&amp;nbsp; &amp;nbsp; &amp;nbsp;Combined ADHD</strong>: {ADHDcomb.NAOK}</p><p><strong>&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ODD</strong>: {if(ODDcount.NAOK ge 8 and PERFcount.NAOK ge 1, 'YES','NO')}</p><p><strong>&amp;nbsp; &amp;nbsp;Conduct Disorder</strong>: {if(CDcount.NAOK ge 3 and PERFcount.NAOK ge 1, 'YES','NO')}</p><p><strong>Anxiety/Depression</strong>: {if(ANXDEPcount.NAOK ge 7 and PERFcount.NAOK ge 1, 'YES','NO')}</p>

And I moved the ADHDComp to below the other equations.

I wasn't sure what you meant by

Remove the text inside your equations

. Did you just mean the Summ equation (Diagnostic Likelihood)? I can't see any text there. Or is it throughout the other equations too. I just can't see what text you mean

Would you mind uploading the lss with your modifications? I am pretty sure I can work it out if I can see what you've actually done.

I appreciate the help. It's ok if this is asking too much. I don't really need the summary. It just feels more complete with it :dry:
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #193844 by Joffm
Replied by Joffm on topic Problems with conditional logic
I talked about this:

<p>Conduct Disorder Screen: {sum(if(G02Q02_SQ27.value ge 2, 1, 0), if(G02Q02_SQ28.value ge 2, 1, 0),if(G02Q02_SQ29.value ge 2, 1, 0),if(G02Q02_SQ30.value ge 2, 1, 0), if(G02Q02_SQ31.value ge 2, 1, 0),if(G02Q02_SQ32.value ge 2, 1, 0),if(G02Q02_SQ33.value ge 2, 1, 0),if(G02Q02_SQ34.value ge 2, 1, 0), if(G02Q02_SQ35.value ge 2, 1, 0),if(G02Q02_SQ36.value ge 2, 1, 0), if(G02Q02_SQ37.value ge 2, 1, 0),if(G02Q02_SQ38.value ge 2, 1, 0), if(G02Q02_SQ39.value ge 2, 1, 0),if(G02Q02_SQ40.value ge 2, 1, 0))}</p>

And, I didn't change anything except removing the text and removing the &nbsp;

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #193845 by Joffm
Replied by Joffm on topic Problems with conditional logic
The reason why you should remove this text is:

What you insert into the question text of this equation is stored.
So with this question text you store "Conduct Disorder Screen: 9"

Later you want to do more calculations with this value.

Of course your comparison "CDcount ge 3" will fail.

Joffm

So revise all your equation to remove all HTML. In the HypADDcount is still &nbsp;

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 1 month ago #193846 by DenisChenu
Replied by DenisChenu on topic Problems with conditional logic

Joffm wrote: So revise all your equation to remove all HTML. In the HypADDcount is still &nbsp;

Best is to use dedicated settings equation for the value without any string and text . And no HTML editor to add new lines etc ...

And use question text part to show to user.

You can even use this Conduct Disorder Screen: {self.NAOK}

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • dralistair
  • dralistair's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 1 month ago #193856 by dralistair
Replied by dralistair on topic Problems with conditional logic
Thanks to both Joffm and DenisChenu.

Your suggestions were helpful. The Summary stuff is now working.

You have also helped me to better understand the workflow and process for developing these types of calculations in surveys.

I am putting a lot of my clinical assessment tools onto my server and your advice has helped tremendously.

Cheers
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose