Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
kavyadwh91
Contributor III
Contributor III

Display Y-axis format dynamic based on expression values in Bar chart

Hi All,

I need to display Y axis in different formats(currencies, percentages, whole numbers) based on the response type filter .

And formats should change based on the expression value.

Please help me .

Here is my expression  

=if(match(ResponseType,'###,###,###,##0.0%'),
num(sum({<Metric_or_Datapoint= {'Metric'}, D1Quarter=>} Value)/100,'#,##0.0%')
,if(match(ResponseType,'###,###,###,##0.00%'),
num(sum({<Metric_or_Datapoint= {'Metric'}, D1Quarter=>} Value)/100,'#,##0.00%')
,

if(match(ResponseType,'###,###,###,##0%'),
num(sum({<Metric_or_Datapoint= {'Metric'}, D1Quarter=>} Value)/100,'#,##0%'),

if(match(ResponseType,'$###,###,###,##0'),
num(sum({<Metric_or_Datapoint= {'Metric'}, D1Quarter=>} Value),'#,##0'),

if(match(ResponseType,'###,###,###,##0.0'),
num(sum({<Metric_or_Datapoint= {'Metric'}, D1Quarter=>} Value),'#,##0.0'),


if(match(ResponseType,'###,###,###,##0'),
num(sum({<Metric_or_Datapoint= {'Metric'}, D1Quarter=>} Value),'#,##0'),

sum({<Metric_or_Datapoint= {'Metric'}, D1Quarter=>} Value)

))))))

 

Thanks in advance

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Since ResponseType already contains the format pattern, you could code a single expression like:

num(sum({<Metric_or_Datapoint= {'Metric'}, D1Quarter=>} Value)/100, ResponseType)

Now the only issue is whether you should divide by 100 or not.  You could take care of that by adding:

num(sum({<Metric_or_Datapoint= {'Metric'}, D1Quarter=>} Value)/if(ResponseType like '*%', 100, 1), ResponseType)

So one expression instead of many.

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

View solution in original post

2 Replies
QFabian
MVP
MVP

Hi, are you ever try using grouped expressions?

With that you can have all your expressions formated independent, and just select what to show

QFabian_0-1604600040869.png

 

QFabian
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Since ResponseType already contains the format pattern, you could code a single expression like:

num(sum({<Metric_or_Datapoint= {'Metric'}, D1Quarter=>} Value)/100, ResponseType)

Now the only issue is whether you should divide by 100 or not.  You could take care of that by adding:

num(sum({<Metric_or_Datapoint= {'Metric'}, D1Quarter=>} Value)/if(ResponseType like '*%', 100, 1), ResponseType)

So one expression instead of many.

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com