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

Help with Num function

Hi All,

For the below expression my expected output was 1 but it returns 0. I know num do not do the rounding.

How can we then get output as 1, i dont want to use round or ceil functions, since i have multiple values with different formats and i am controlling the formats using a different excel sheet.

=if(num(3.52,'###0') >=num(3.54,'###0'),1,0)

 

Best Regards,
KC
Labels (1)
4 Replies
tresesco
MVP
MVP

You are correct that num() doesn't round the numbers. To be precise, it doesn't change the value of the numbers but just change the format(appearance). That means, if you are writing:

num(3.52,'###0') >=num(3.54,'###0'), you are actually comparing 3.52>=3.54 which is always FALSE.

 

for your problem, you have to look for alternate way of handling different formats but num(). Try to explain your case with sample - we could give a try help.  

 

jyothish8807
Master II
Master II
Author

Thanks Tresesco for the prompt reply. Even i thought the same.

In that case, =if(num(round(3.52),'###0') >=num(round(3.54),'###0'),1,0) should fix the issue. 

Also if i use the round function outside of num function, again it dosent work, do you know why is it so ?

In my case i have multiple entries like below:

A   5.6789

B 5.4

C 8.889

And each entries should be displayed in different ways, so as of now i use an excel file which have the format mapping like this:

A  '##0'

B '##0.0' etc

 

I believe i missed the rounding logic, i am planing to add the rounding values like 1 or 0.01 for the respective values in the above mapping along with the format. Hope that fix my issue.

Please let me know if this works or you has a better solution 🙂

Thanks in Advance!

Br,

KC

Best Regards,
KC
tresesco
MVP
MVP


@jyothish8807 wrote:

Also if i use the round function outside of num function, again it dosent work, do you know why is it so ?

 


It should work, and it is working with me. I tried like below and it works. However, it doesn't make much sense to me using round() outside num().

 

=if(round(num((3.52),'###0')) >=round(num((3.54),'###0')),1,0)

 

 

The rest part of having various number formats .. I couldn't really follow why you are doing so.🤔 

jyothish8807
Master II
Master II
Author

Hi,

Yes, it does work.. my bad i made a typo.

In my case each entries are different KPIs and each have a different format of display in the staright chart. Some will be in %, some will be in euros etc. 

 

Br,

KC

Best Regards,
KC