Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
I have a line chart where I want to set the number format dynamically based on a variable.
For my measure I want to be be able to toggle between Num(Sum(Sales), '0.000') or Num(Sum(Sales), '$#0.00')
Both of these measure work individually. However, when I put them in an if statement, the number format stops applying:
If( True(), Num(Sum(Sales), '0.000') , Num(Sum(Sales), '$#0.00'))
Does anyone have any idea how I can get this resolved?
Thanks in advance
Colm,
It looks like it should work to me. The True() looks like it is just for testing - how are you getting the value of the variable in the If statement?
Hi John,
Thanks for the reply. The True() is just for testing - I want to get the expression working with that before looking into the variable.
You can reproduce the behavior I'm looking on Qlik Sense Feburary 2018 edition with the following:
Load Script:
LOAD * INLINE
[
Item,Sales
A, 100
B, 200
]
Charts:
Line chart one (working, formatted with dollar)
Dimension: Item
Measure: Num(Sum(Sales),'$#.00')
Line chart two (working, formatted with four decimals)
Dimension: Item
Measure: Num(Sum(Sales),'#.0000')
Line chart three (not working, if statement)
Dimension: Item
Measure: If(True(), Num(Sum(Sales),'$#.00'), Num(Sum(Sales),'#.0000'))
In all cases, the number formatting dropdown on the measure is set to 'Auto'
What is True() evaluating? Won't it always return "-1" in your expression?
Yes, I've just added the true() as a test. In my real expression I would have a variable here that would vary between true() and false().
You can create 2 buttons to toggle between.
Try extension http://branch.qlik.com/#!/project/56728f52d1e497241ae697f8
If you are using a variable named vVar for buttons with values 1 and 2, then your expression will be
if(vVar = 1, Num(Sum(Sales), '0.000') , Num(Sum(Sales), '$#0.00') )
Colm,
I tried it and got it to work when the Number Formatting for the column was set to Auto or Measure expression.
Did you have any luck yet?
John,
Ok, that's weird! I have the exact same set up and yet the formatting is not being applied.
I'm on Qlik Sense Desktop Februry 2018 (12.5.2), what version are you on?