Skip to content

Instantly share code, notes, and snippets.

Created December 14, 2016 14:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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)))

@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?

Copy link

@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