Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Is the problem the comma?

Hi to everyone,

I'm new in qlikview but i'm going mad with this problem.

I need to parse the entire result set of a load to find the row with minimun value of a ratio of two field.

This is the code that i did

let ratioMin=1;

let ratioMax=0;

For i = 1 to NoOfRows('Table')

  LET vNumA=FieldValue('NumberA',$(i));

  LET vNumB= FieldValue('NumberB',$(i));

  LET vNewRatio=$(#vNumA)/$(#vNumB);

  if( $(ratioMin)>>$(vNewRatio)) then

   let ratioMin=$(vNewRatio);

   let vUteDanMin=FieldValue('Utente',$(i));

  end if

next

The script return error, and with the debug i saw that the variable vNewRatio assume value like 0,066666666666667 with comma separator.

The returned message is this:

"Script line error:

if( 1>>0,066666666666667) then"

Is that the problem? How can i fix it?

thanks a lot

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi,

Yes, the FieldValue() would be the case, but that's easy to fix, just modify the lines

LET vNumA = Num(FieldValue('NumberA',$(i)));

And if that does not work:

LET vNumA = Num(Num#(FieldValue('NumberA',$(i)), '#,#'));

You can even specify the decimal and thousand separator in the Num() function without need to represent with the Num#() function

Hope that helps.

Miguel

View solution in original post

14 Replies
Miguel_Angel_Baeyens

Hi,

Use just ">" instead of ">>" (the latter is a unary operator, unlikely to be used here). That should work just fine.

Hope that helps.

Miguel

Not applicable
Author

Hi Miguel,

I tried your solution but doesn't work. There is always the error, now with one ">".

However thank you for the information

Alessio

Miguel_Angel_Baeyens

Hi Alessio,

Try the following:

IF Num($(ratioMin)) > Num($(vNewRatio)) THEN

Hope that helps.

Miguel

Not applicable
Author

Hi again,

i tryed also this but dosn't work

the variable NUM(vNewRatio) assume value lik this 066666666666667 instead 0,66666666666667, and the IF don't work properly.

I think the problem is the ',' that the ratio give back to the variable instead the '.'  as decimal separator as usual, but i don't understand why

Thanks a lot


Alessio

Miguel_Angel_Baeyens

Hi Alessio,

What do your script variables ThousandSep, DecimalSep and so store? Are they properly set up and according to your computer local settings?

Miguel

EDIT: Attached an example. If you remove the Num() function in the If, it crashes, otherwise it works as expected.

Not applicable
Author

These are my eviroment variable:

SET ThousandSep='.';

SET DecimalSep=',';

SET MoneyThousandSep='.';

SET MoneyDecimalSep=',';

SET MoneyFormat='€ #.##0,00;-€ #.##0,00';

SET TimeFormat='hh:mm:ss';

SET DateFormat='DD/MM/YYYY';

SET TimestampFormat='DD/MM/YYYY hh:mm:ss[.fff]';

SET MonthNames='gen;feb;mar;apr;mag;giu;lug;ago;set;ott;nov;dic';

SET DayNames='lun;mar;mer;gio;ven;sab;dom';

I tryed also to switch ThousandSep and DecimalSep .

SET ThousandSep=',';

SET DecimalSep='.';

but the problem is still there.

My local setting of  Decimal Separator is ','. Do you think is that?

Thanks a lot

Miguel_Angel_Baeyens

Alessio,

Does my app run fine when you load it?

Miguel

Not applicable
Author

Sorry i have the personal edition for the moment, can you paste the just the code?

I tried to change the windows enviroment variable but nothing is changed

Alessio

Miguel_Angel_Baeyens

Alessio here you are,

// Same variables as you have

LET vNum1 = 2;

LET vNum2 = 3;

LET vRatio = $(vNum1) / $(vNum2); // To make sure the result is a long decimal number 0,6666666667

IF Num($(vRatio)) > 1 THEN // This works, enters the IF part

     SET vRatioOK = 0;

ELSE

     SET vRatioOK = 1;

END IF

You will see the variable vRatioOK = 0, that means that has run as expected

Miguel