- Posts: 17
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Problem with decimal mark
- Fgonc124
- Topic Author
- Offline
- New Member
Less
More
3 years 5 months ago #207395
by Fgonc124
Problem with decimal mark was created by Fgonc124
I created a quizz where I calculate IMC.
I have comma as a decimal mark.
I used a formula to attribute the interval of IMC
The IMC formula is
{round(Weight/(Height*Height/100/100),2)}
To evaluate IMC interval I have this formula
{if(IMC<25,0,if(IMC>=25 and IMC<=30,1,if(IMC>30,3)))}
With comma as decimal mark the if condition does not work. It looks like the if function "thinks" the comma near 30 ( IMC<=30,) is a decimal mark instead of a parameter.
With decimal mark as dot it works fine
I tried to use fixnum(IMC) but didn't work
Is there a way to make this work with decimal mark as comma?
I send my quizz as an attach
Thanks
I have comma as a decimal mark.
I used a formula to attribute the interval of IMC
The IMC formula is
{round(Weight/(Height*Height/100/100),2)}
To evaluate IMC interval I have this formula
{if(IMC<25,0,if(IMC>=25 and IMC<=30,1,if(IMC>30,3)))}
With comma as decimal mark the if condition does not work. It looks like the if function "thinks" the comma near 30 ( IMC<=30,) is a decimal mark instead of a parameter.
With decimal mark as dot it works fine
I tried to use fixnum(IMC) but didn't work
Is there a way to make this work with decimal mark as comma?
I send my quizz as an attach
Thanks
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3595
3 years 5 months ago - 3 years 5 months ago #207398
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 Problem with decimal mark
Try introducing some decimal positions and spaces.
Code:
{if(IMC<25,0 , '0' , if(IMC>=25,0 and IMC<=30,0 , '1' , if(IMC>30,0 , '3')))}
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 years 5 months ago by tpartner.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
3 years 5 months ago #207408
by DenisChenu
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.
Replied by DenisChenu on topic Problem with decimal mark
Can you send a lss ?
Comma have issue, but i never see such issue …
Comma have issue, but i never see such issue …
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.
- Fgonc124
- Topic Author
- Offline
- New Member
Less
More
- Posts: 17
- Thank you received: 1
3 years 5 months ago #207409
by Fgonc124
Replied by Fgonc124 on topic Problem with decimal mark
I just sent you an example
Attachments:
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12937
- Thank you received: 3979
3 years 5 months ago #207411
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Problem with decimal mark
Hi,
Don't show "all on one page".
With this - shortened - equation
{if(IMC lt 25, 0 ,if(IMC le 30,1,3))}
or
Joffm
Don't show "all on one page".
With this - shortened - equation
{if(IMC lt 25, 0 ,if(IMC le 30,1,3))}
or
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- Fgonc124
- Topic Author
- Offline
- New Member
Less
More
- Posts: 17
- Thank you received: 1
3 years 5 months ago #207413
by Fgonc124
Replied by Fgonc124 on topic Problem with decimal mark
Thanks it worked
The problem was that on last IF I didn't write a value case the condition was false. If I write a value the formula works.
But you were right I didn't need the last if.
Thanks
The problem was that on last IF I didn't write a value case the condition was false. If I write a value the formula works.
But you were right I didn't need the last if.
Thanks
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13648
- Thank you received: 2491
3 years 5 months ago #207418
by DenisChenu
But here , as separator seems to broke the test.
To fix the issue : you can use «{if((round(Weight/(Height*Height/100/100),2))<25, 0 ,if((round(Weight/(Height*Height/100/100),2))>=25 and (round(Weight/(Height*Height/100/100),2))<=30,1,if((round(Weight/(Height*Height/100/100),2))>=30,3)))}» in all in one page survey … not the best but it work.
Since it's a LimeSUrvey issue : it must be reported (in my opinion).
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.
Replied by DenisChenu on topic Problem with decimal mark
In my opinion : it must work in all in one page, i didn't really see the issue in expression,Joffm wrote: Hi,
Don't show "all on one page".
But here , as separator seems to broke the test.
To fix the issue : you can use «{if((round(Weight/(Height*Height/100/100),2))<25, 0 ,if((round(Weight/(Height*Height/100/100),2))>=25 and (round(Weight/(Height*Height/100/100),2))<=30,1,if((round(Weight/(Height*Height/100/100),2))>=30,3)))}» in all in one page survey … not the best but it work.
Since it's a LimeSUrvey issue : it must be reported (in my opinion).
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.
- Fgonc124
- Topic Author
- Offline
- New Member
Less
More
- Posts: 17
- Thank you received: 1
3 years 5 months ago #207419
by Fgonc124
Replied by Fgonc124 on topic Problem with decimal mark
Hi
Thank you for your answer
The problem was in formula.
{if(IMC<25,0,if(IMC>=25 and IMC<=30,1,if(IMC>30,3)))}
The last if condition does not have a value when evaluate to false.
If I add a value it works fine with comma as decimal mark.
Any way, I don't need the last if condition.
Thanks
Thank you for your answer
The problem was in formula.
{if(IMC<25,0,if(IMC>=25 and IMC<=30,1,if(IMC>30,3)))}
The last if condition does not have a value when evaluate to false.
If I add a value it works fine with comma as decimal mark.
Any way, I don't need the last if condition.
Thanks
The following user(s) said Thank You: DenisChenu
The topic has been locked.