Forum Discussion
Dynamic Y-axis max on a shared line chart (measure switch + field parameter).
- 11 months ago
Detecting which field parameter option (D/W/M/Q/Y) is currently selectedNot supported by the current design of the Field Parameters. Even worse, in multi select options you can not know the order in which the report user picked the values.
Anonymous
Thank you for the detailed response.
Your suggested approach would work well if my Y-axis scaling were controlled only by the Revenue, Cost, and Cost % measures.
However, in my case, the scaling is also influenced by a Calendar field parameter that dynamically changes the X-axis grain (D, W, M, Q, Y).
Selecting D switches the X-axis to Day level
Selecting W switches it to Week level, and so on
Here’s where the challenge arises:
I have four KPIs — Sales Score, Total Sales, Total Profit, and Profit %.
For Sales Score and Profit %, I need to set a fixed Y-axis range (100 and 100% respectively).
For Total Sales and Total Profit, Power BI’s auto-scaling works well and should remain as-is.
The difficulty is that when I fix a manual range for metrics like Total Sales, the visual looks incorrect because the scale should vary by time grain (Year > Quarter > Month > Week > Day).
I considered writing a DAX formula to dynamically determine the Y-axis max, but I need a reliable way to capture the state of the field parameter (which represents the selected time grain).
Unfortunately, using SELECTEDVALUE() on the field parameter’s [Field] column throws a composite key error.
I’m trying to find the best practice for:
Detecting which field parameter option (D/W/M/Q/Y) is currently selected.
Using that selection along with the chosen KPI to calculate a dynamic Y-axis max that mixes both fixed and auto-scaled behaviors.
Detecting which field parameter option (D/W/M/Q/Y) is currently selected
Not supported by the current design of the Field Parameters. Even worse, in multi select options you can not know the order in which the report user picked the values.