Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
limu
Partner - Contributor II
Partner - Contributor II

DIvision not working

Hello everyone,

I have the following script:

 

 

LET vVar1 = $(vVar2) / $(vVar3);
LOAD * INLINE [
   StatusName, Value
   $(StatusName), $(vVar1)
];

 

 

The vVar2 and vVar3 are not zero and the value of vVar2 changes since this code snippet is inside of a FOR loop. However, the result becomes always zero. Since the vVar3 > vVar2, the result must be  (0, 1), i.e. in the range of 0 and 1 exclusively.

Does anyone know where the problem might be?

Thank you in advance!

UPDATE: I figure it out that the division is actually working, is just that it is rounding down the numbers to 0. When I multiple these numbers by 100, I'm getting the correct results. Does anyone know how to display these number as percentage? Example, the number 1234 to display it as 12,34. Num($vVar1, '#,##0.00%'); is not working!

Labels (4)
3 Replies
JordyWegman
Partner - Master
Partner - Master

Hi Limu,

Try this:

Num('$(vVar1)', '#,##0.00%')

Else:

 Let vVar1 = Num($(vVar2) / $(vVar3),'#,##%');

Jordy

Climber 

Work smarter, not harder
limu
Partner - Contributor II
Partner - Contributor II
Author

Hi Jordy,

thank you very much for your suggestions! Unfortunately, neither of them isn't working!

It may be worth noting, that the numbers that I have, are not of the same length, i.e. some number have only one digit like 1, other have two like 12, and so on up to 4 digits. I tried using '#.##%' and it worked only for the numbers that had three digits. Is there a way to add leading zeros to the numbers that have less than 4 digits, so that all the numbers have the same number of digits(4).  

JordyWegman
Partner - Master
Partner - Master

Can you maybe send some test data & QVF so I can test this?

Jordy

Climber

Work smarter, not harder