Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Num( Function not working

Good Morning All,

I have been using the num function without issue in all my Qlik Charts but for some reason I cannot get it to work in the following:

'LY - ' & if (GetCurrentSelections(Year)=2016,

num(Sum({<_YTD_LY={1}>} [Sales total with VAT])

/ Count({<_YTD_LY={1}>} DISTINCT [Sales invoice]), '£#.##'),

num(Sum({<[Year]={"$(=max([Year]-1))"}>} [Sales total with VAT])

/ Count({<[Year]={"$(=max([Year]-1))"}>} DISTINCT [Sales invoice]), '£#.##'),

)


This does not format the number at all. As a result, instead of £15.42 I instead have 15.419583493 (for example). Also, if it helps, this is under the Subtitle field in Qlik Sense.

I appreciate any assistance you can give me with regards to this issue.

Thank you in advance.

Kind regards,

Michael

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Try putting the num on the outside of the if statement.


talk is cheap, supply exceeds demand

View solution in original post

6 Replies
Gysbert_Wassenaar

Try putting the num on the outside of the if statement.


talk is cheap, supply exceeds demand
jpenuliar
Partner - Specialist III
Partner - Specialist III

you seem to have an extra comma "," within your IF statement.

'LY - ' &

if (GetCurrentSelections(Year)=2016

    ,num(Sum({<_YTD_LY={1}>} [Sales total with VAT])/Count({<_YTD_LY={1}>} DISTINCT [Sales invoice]), '£#.##')

    ,num(Sum({<[Year]={"$(=max([Year]-1))"}>} [Sales total with VAT])/Count({<[Year]={"$(=max([Year]-1))"}>} DISTINCT [Sales invoice]), '£#.##')

    ,   <<<<<<<<<<<<<<< this one

    )

ToniKautto
Employee
Employee

Is pound £ your currency format in the application?

If so, I would suggest that you confirm the money variables in the load script are set according to your preference, for example as below.

SET MoneyThousandSep=',';

SET MoneyDecimalSep='.';

SET MoneyFormat='£#,##.00;£-#,##.00';

Being currency, you then us the Money() format function.

'LY - ' & if( GetCurrentSelections(Year)=2016,

Money(Sum({<_YTD_LY={1}>} [Sales total with VAT]) / Count({<_YTD_LY={1}>} DISTINCT [Sales invoice]) ),

Money(Sum({<[Year]={"$(=max([Year]-1))"}>} [Sales total with VAT])/Count({<[Year]={"$(=max([Year]-1))"}>} DISTINCT [Sales invoice])))

Not applicable
Author

Thank you, this worked. It seems so obvious now!

Kind regards,

Michael

Not applicable
Author

My apologies, this is part of a larger expression and was poorly edited.

Kind regards,

Michael

Not applicable
Author

It is indeed setup correctly in the load script, but thank you very much for the advice re:"Money()" - this will be useful for my future multi-currency analysis.

Kind regards,

Michael