Setting the y-axis range the same from two bar plot with different alternate states in Qliksense
Asked Answered
I

1

7

This video (https://www.youtube.com/watch?v=tsbnG3tOdR4&feature=emb_logo) shows how to implement alternate state to create two bar plots to compare values in Qlik sense.

I have a follow-up question: for these two bar plots, is it possible to make the y-axis range the same depends on the overall selected values from both alternate states?

I know we can manually set the y-axis limit in Appearance -> Y-axis -> Range. However, since the selected data are from two different alternate states, I don't know how to write an expression to set the range the same for both bar plots.

Ioved answered 27/5, 2020 at 15:18 Comment(0)
G
1

It's hard to give a specific answer without knowing what relation you need between the values in the alternate states and the range (happy to elaborate if you can provide more detail).

But the key thing is that you can get to the alternate states using set analysis.

Say that I have two bar charts in an insurance app that both have one dimension 'Claim Type' and one measure 'Average Claim Amount'. The first uses 'State 1' and the second uses 'State 2'.

I want the y-axis range to be bound by the largest bar displaying in either of these two charts.

I could use the following as my y-axis max:

=RangeMax(
    Max({'State 1'} Aggr(Avg({'State 1'} [Total Claim Cost]), [Claim Type])),
    Max({'State 2'} Aggr(Avg({'State 2'} [Total Claim Cost]), [Claim Type]))
)

The first argument in RangeMax is using an Aggr() function to dynamically create a table of average claim amount per type under the State 1 selection, and taking the max of these (ie. the value of the tallest bar in State 1).

The second argument does the same thing to find the value of the tallest bar in State 2.

Finally, the RangeMax returns the higher of these.

Note that you can use set operators to combine the selections in these states together. Say if I wanted to display some text above the bar charts that displays the value of the largest single claim under the selections in either state. I could use the '+' operator to run my calculation across the union of the states:

=Max({'State 1'+'State 2'} [Total Claim Cost])

The '+' in this context is called a Set Operator, there are other ones available allowing you to combine alternate states in various ways. See here for some more detail and examples: https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/ChartFunctions/SetAnalysis/set-analysis-expressions.htm

Garmaise answered 19/9, 2020 at 7:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.