Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
sridhar1
Contributor III
Contributor III

Dynamic Label for Measure Expression in Bar Chart

Hi All,

I have basic Bar Chart and Variable Extension used to toggle between Metrics( Volume and Sales) by Period.

Defined vMetric=1 in load Script

Created values in Variable Extension

1= Volume

2= Sales

So In Measure expression I have written as

if(vMetric=1, Sum(Volume),

if(vMetric=2,Sum(Sales))

Dimension: YearMonth

Now my Bar Chart show me Metric values for every YearMonth as

if(vMetric=1, Sum(Volume),

if(vMetric=2,Sum(Sales)):    20.5

when Volume is select in Variable extension Toggle.

I need as

Volume: 20.5 when Volume is selected in Toogle

Sales: 100. 7 when Sales is selected in Toogle.

Let me know your thoughts please

Thanks

Sridhar

4 Replies
rubenmarin

Hi Sridhar, seems the variable value isn't changing, can you check that the variable really toggles it's value? If the variable doesn't changes maybe you need to update the version of the extension.


You can also try manually setting the variable value to '2' to check the expression.

sridhar1
Contributor III
Contributor III
Author

Hi Ruben,

Variable is working and values are Changing when I toggle between Volume and Sales.

If I select Volume the value on bar shows as

if(vMetric=1, Sum(Volume),

if(vMetric=2,Sum(Sales)):    20.5

If I select Sales the value on bar show as

if(vMetric=1, Sum(Volume),

if(vMetric=2,Sum(Sales)):    100.7

It is showing the Expression : Value on bars..instead I want to show Label : Value( Volume: 20.5 and Sales: 100.7 based on the toggle selection)

Thanks

Sridhar

rubenmarin

Ok, now I understand where is the problem. I don't know a way to dinamically assign a dynamic column label in a bar chart, in a pivot table you can use dynamic titles with $-expansion like $(=If(vMetric=1, 'Volume', 'Sales') but this doesn't works on bar chart.

I didn't tried yet, but you can take a look at this document: Emulating dynamic labels in Qlik Sense

sridhar1
Contributor III
Contributor III
Author

Thanks Ruben for suggestion. I will try out that option and let you know.

Thanks

Sridhar