Welcome to the LimeSurvey Community Forum

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

Problem with decimal mark

  • Fgonc124
  • Fgonc124's Avatar Topic Author
  • Offline
  • New Member
  • New Member
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

File Attachment:

File Name: limesurvey...mark.lsq
File Size:1 KB

File Attachment:

File Name: limesurvey...mark.lsq
File Size:1 KB
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
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago - 3 years 5 months ago #207398 by tpartner
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
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #207408 by DenisChenu
Replied by DenisChenu on topic Problem with decimal mark
Can you send a lss ?

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
  • Fgonc124's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 5 months ago #207409 by Fgonc124
Replied by Fgonc124 on topic Problem with decimal mark
I just sent you an example
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #207411 by Joffm
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

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Fgonc124
  • Fgonc124's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
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 topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #207418 by DenisChenu
Replied by DenisChenu on topic Problem with decimal mark

Joffm wrote: Hi,
Don't show "all on one page".

In my opinion : it must work in all in one page, i didn't really see the issue in expression,

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
  • Fgonc124's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
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
The following user(s) said Thank You: DenisChenu
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose