- Posts: 7
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
How to convert a string to integer
- ishgem
- Topic Author
- Offline
- New Member
Less
More
7 years 7 months ago #141067
by ishgem
How to convert a string to integer was created by ishgem
Dear Admin,
I used an if statement for assessment questions , the calculated value output NAN in database, but is showing the exact value in the frontend during the survey session! How can I convert the selected value into integer?
Thanks in advance!
I used an if statement for assessment questions , the calculated value output NAN in database, but is showing the exact value in the frontend during the survey session! How can I convert the selected value into integer?
Thanks in advance!
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
7 years 7 months ago #141076
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How to convert a string to integer
Can you attach a small exported .lss file containing only the pertinent questions.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- ishgem
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
7 years 7 months ago #141078
by ishgem
Replied by ishgem on topic How to convert a string to integer
firstly, thank you for the reply and your time.
while trying to overcome the issue with assessment value in decimal places, that was why I used the if condition stated below:
{if(aop1_SQ1.value==10,'10',if(aop1_SQ1.value==7,'7.5',if(aop1_SQ1.value==5,'5',if(aop1_SQ1.value==2,'2.5',if(aop1_SQ1.value==0,'0',if(aop1_SQ1.value==-1,'""','""'))))))} for all the question that has decimal values.
second if condition was used for total score grade
{if(aop1_SQ001.value =="-1",'""', '20')}
the total sum for participant
{sum(totalEFBH.value,totalAM.value,totalAT.value)} /* score1 */
the overall total score for the denominator
{sum(maxscoreEFBH.value,maxscoreAM.value,maxscoreAT.value)} /* totalgradescore */
score1/totalgradescore
Thank you in advance!
while trying to overcome the issue with assessment value in decimal places, that was why I used the if condition stated below:
{if(aop1_SQ1.value==10,'10',if(aop1_SQ1.value==7,'7.5',if(aop1_SQ1.value==5,'5',if(aop1_SQ1.value==2,'2.5',if(aop1_SQ1.value==0,'0',if(aop1_SQ1.value==-1,'""','""'))))))} for all the question that has decimal values.
second if condition was used for total score grade
{if(aop1_SQ001.value =="-1",'""', '20')}
the total sum for participant
{sum(totalEFBH.value,totalAM.value,totalAT.value)} /* score1 */
the overall total score for the denominator
{sum(maxscoreEFBH.value,maxscoreAM.value,maxscoreAT.value)} /* totalgradescore */
score1/totalgradescore
Thank you in advance!
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
7 years 7 months ago #141092
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How to convert a string to integer
Try removing the quotes from around the numeric values. Expression Manager (like JavaScript) will interpret anything enclosed in quotes as a string.
Code:
{if(EFBH001_SQ001.value==10, 10, if(EFBH001_SQ001.value==0, 0, 0))}
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: ishgem
The topic has been locked.
- ishgem
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
7 years 7 months ago #141097
by ishgem
Replied by ishgem on topic How to convert a string to integer
thanks so much! am glad for reply. I will surely try it out and get back to you.
The topic has been locked.
- ishgem
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
7 years 7 months ago - 7 years 7 months ago #141098
by ishgem
Replied by ishgem on topic How to convert a string to integer
Please how can I add a NULL should it be ' ' or " ", or how? I need a NULL value if the N/A is selected.
Also when I pass a variable from a group to another to get an average value is always zero, and it wasn't like initially.
{sum(totalEFBH.value,totalAM.value,totalAT.value)}
{sum(maxscoreEFBH.value,maxscoreAM.value,maxscoreAT.value)} // am getting zero for some these variables.
{(totalAMBIENCE.value/maxAMBIENCE.value)*100} //
Please help me out!
Thanks a Zillion!
Also when I pass a variable from a group to another to get an average value is always zero, and it wasn't like initially.
{sum(totalEFBH.value,totalAM.value,totalAT.value)}
{sum(maxscoreEFBH.value,maxscoreAM.value,maxscoreAT.value)} // am getting zero for some these variables.
{(totalAMBIENCE.value/maxAMBIENCE.value)*100} //
Please help me out!
Thanks a Zillion!
Last edit: 7 years 7 months ago by ishgem.
The topic has been locked.
- ishgem
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
7 years 7 months ago #141104
by ishgem
Replied by ishgem on topic How to convert a string to integer
Good Day Mr. Tpartner, Am still getting the same result. :dry:
I tried what you said but to no avail. Passing a calculated variable from one group to another some are still showing zero. I thought it was a string, and after removing those quotes I still have the same problem.
Please anyway out?
I tried what you said but to no avail. Passing a calculated variable from one group to another some are still showing zero. I thought it was a string, and after removing those quotes I still have the same problem.
Please anyway out?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
7 years 7 months ago #141112
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic How to convert a string to integer
I'm sorry, there are far to many equations in your survey for me to debug every one. I would start by leaving all equation questions visible so you can see their values real-time.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- ishgem
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
7 years 7 months ago - 7 years 7 months ago #141118
by ishgem
Replied by ishgem on topic How to convert a string to integer
ok.. Thank you for your time and response.
Last edit: 7 years 7 months ago by ishgem.
The topic has been locked.
- ishgem
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
- Thank you received: 0
7 years 7 months ago #141134
by ishgem
Replied by ishgem on topic How to convert a string to integer
EUREKA!!!!
I got it! Thanks so much for the time and concern. I really appreciate it. However, I will get back to you.
I got it! Thanks so much for the time and concern. I really appreciate it. However, I will get back to you.
The topic has been locked.