Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
Not applicable

num() not working in if Statement

I am having issues with if condition in Qlik sense app. I am trying to format measures based on variable. The format works by itself outside of the If statement but when I include it in if statement it does not work. Below is the statement

The format works but 'k' does not show up on the charts. so the number 712100 shows as 712.1

IF(fabs($($(vToggleDatePeriod)_New_$(vToggleLOB)_$(vToggleMetric)))>1000,num(round($($(vToggleDatePeriod)_New_$(vToggleLOB)_$(vToggleMetric))/1000,.1),'#,##0.0k;(#,##0.0k)'),

round($($(vToggleDatePeriod)_New_$(vToggleLOB)_$(vToggleMetric)),.01))

The below works and the measures on the bar  chart shows with the 'k' format. so the number 712100 shows as 712.1k

num(round($($(vToggleDatePeriod)_New_$(vToggleLOB)_$(vToggleMetric))/1000,.1),'#,##0.0k;(#,##0.0k)')

Thanks for help in advance!

Tags (2)
10 Replies
ogster1974
Honored Contributor II

Re: num() not working in if Statement

‌sounds like your if stateMent is resolving itself on the other side oythe condition?  Debugging your variables should help you find the issue.  An if statement in itself will not restrict formatting.

reddys310
Honored Contributor II

Re: num() not working in if Statement

Hi Vandy,

it could be that the output is already in num() format. As Andy suggested, Debugging it with a variable should help you solve the issue.

Not applicable

Re: num() not working in if Statement

Thanks for your input Andy and Sangram! I tried looking at it using variables and the variable shows the numbers as expected - 712.1k. Its weird ...

Andy,

to answer your questions. The if statement is resolving to the if and not else as we see the /1000 in the final result. it is also doing the formatting to 1 decimal but not appending 'k'.

Re: num() not working in if Statement

Hi Vandy, maybe that expression has a format set in the "numbers" tab, if it has any format, set the first option ('Expression default'?) to avoid that the format in this tab overrides your expression format.

Not applicable

Re: num() not working in if Statement

Ruben,

I think the issue is with the 'Auto' formatting, I have it set for the measure. I tried with other options but nothing seems to work. Any ideas you can provide as to how I can define the number format based on a condition?

Thanks!

Re: num() not working in if Statement

Hi Vandy, logic seems ok and is working, because of that I'm looking for any other reason overriding what your expression does.

I attach an example changing "$($(vToggleDatePeriod)_New_$(vToggleLOB)_$(vToggleMetric))" to "721100", it shows the 'k' in every place of the bar chart. Check if there are any differences with your chart.

Not applicable

Re: num() not working in if Statement

Ruben,

Thanks for the sample doc, unfortunately I am using Qlik Sense .

Vandy

Re: num() not working in if Statement

Oops, sorry, I didn't see that.

ogster1974
Honored Contributor II

Re: num() not working in if Statement

Ok Vandy here is where I think we are with this issue.

You have a chart that displays a measure in a different format dependent on which side of the IF statement it resolves to.

You could use the custom format option for your measure but as you can see its not set by expression so need to be one way or another.

The label for measures is also set statically at present so you need some way to show the user the measure format for the chart when it is in a certain condition.

Have you considered changing the title, sub title or footnote of your chart to be dynamically set basis on the if statement.  Would that go some way to resolving your issue.  Without a mock-up of the end result you are trying to achieve its hard to visualise.