Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Qlik Nice Number Format
//---------------------------------------------- Nice Numberformat simplified ---------------------------------------------
// does work with count in KPI object (have seen several versions from Qlik which haven't worked)
Set vF_NiceNumberSimple =
If(Fabs($1) > 1e9, Num($1/1e9+1e-13, '#$(ThousandSep)##0$(DecimalSep)00')
,If(Fabs($1) > 1e8, Num($1/1e6+1e-13, '##0$(DecimalSep)0')
,If(Fabs($1) > 1e6, Num($1/1e6+1e-13, '##0$(DecimalSep)00')
,If(Fabs($1) > 1e5, Num($1/1e3+1e-13,'##0$(DecimalSep)0')
,If(Fabs($1) > 1e3, Num($1/1e3+1e-13, '##0$(DecimalSep)00')
, $1,
))))) &
If(Fabs($1) > 1e9, ' Mrd'
,If(Fabs($1) > 1e8, ' Mio'
,If(Fabs($1) > 1e6, ' Mio'
,If(Fabs($1) > 1e5, ' tsd'
,If(Fabs($1) > 1e3, ' tsd'
, ''
)))))
;
//---------------------------------------------- Nice Numberformat simplified ---------------------------------------------
// usage:
$(vF_NiceNumberSimple(Count(distinct Expression1)))
@MichelLalancetteNortera

@ralfbecher Ralf, I've been doing something similar and I was wondering, why are you concatenating the num format to the text (Mrd, Mio, ...)?
Wouldn't something like this If(Fabs($1) > 1e9, Num($1/1e9+1e-13, '#$(ThousandSep)##0$(DecimalSep)00 Mrd') work just the same and be shorter?

@ralfbecher
Copy link
Author

ralfbecher commented Oct 18, 2021

@MichelLalancette you could be right. Maybe this hasn't worked in the past?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment