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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
maxim1500
Partner - Creator
Partner - Creator

Switching between alternative measures using API

Hi,

I would need to change the active measure on a chart based on a combo box selection in my mashup. The measures are defined in the measures section. I thought the easiest way to do this would be to assign all the measures as alternatives dimensions and set the active one using the mashup API. But I cannot find the method to set the active alternative measure in the documentation.

Is there an API method to set the active measure in a chart? Otherwise, can we change programmatically the measure? I know I can set variables, but I cannot call a measure using a variable as far as I know...

Thank you!

7 Replies
maxim1500
Partner - Creator
Partner - Creator
Author

Actually, I think the alternative dimension idea won't work... I need KPIs to change also, and they don't support alternative dimensions...

Not applicable

Hi,

You can switch or change measures and dimensions with the Qlik Sense .NET SDK ‒ Qlik Sense, You can find more examples on Qlik Branch.

Best regards

Lars-Göran Book

ErikWetterberg

Hi Maxime,

You could use a variable instead and use the variable extension on Qlik Branch. That way you could also change a number of charts, KPIs etc at the same time, with just one click.

Hope this helps

Erik

maxim1500
Partner - Creator
Partner - Creator
Author

Hi,

I figured out how to change the formulas or part of them using variables, but is it possible to point to a predefined measure?

Thanks!

hacr
Creator
Creator

I'm currently searching for similar idea. Did you find a solution using the API?

maxim1500
Partner - Creator
Partner - Creator
Author

Hi Hans,

I did not find how to point to predefined measures, but we are now using variables for each measure, so it would be easy to switch between them.

For example:

LET vL.ClientCost = SUM([Client Costs Field])

LET vL.ClientRevenue = SUM([Client Revenues Field])


LET vL.SwappableMetric = $(vL.ClientCost)


And in your metrics, you could simply use the variable value.

For example, My [Client Costs] metric would be $(vL.ClientCost).

Hope this helps!

hacr
Creator
Creator

Hi Maxime

Thank you for the response! I decided to go another route and generate the Qlik graphs "on the fly" in JavaScript, allowing dynamic switch between dimensions/measures/graph type etc. throught the front-end.