Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
@PowerBI @dax @Visualization I need to create a line chart where both the primary Y-axis and the secondary Y-axis are dynamic based on parameter selections in two slicers, along with the legend selection. However, I'm encountering an issue where I can't add the legend after configuring both Y-axis results, or vice versa. How can I achieve this?
If its not feasible any custom visual will help to solve this?
Solved! Go to Solution.
Hi @as1195 ,
I made simple samples and you can check the results below:
SelectedPrimaryYValue =
SWITCH(
TRUE(),
SELECTEDVALUE('Parameter 2'[Parameter Order]) = 0, SUM('Table'[Percent]),
SELECTEDVALUE('Parameter 2'[Parameter Order]) = 1, SUM('Table'[Number])
)
SelectedSecondaryYValue =
SWITCH(
TRUE(),
SELECTEDVALUE('Parameter'[Parameter Order]) = 0, SUM('Table'[Sale]),
SELECTEDVALUE('Parameter'[Parameter Order]) = 1, SUM('Table'[Cost])
)
An attachment for your reference. Hope it helps!
Best regards,
Community Support Team_ Scott Chang
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Hi @as1195 ,
In Power BI, configuring a dynamic dual Y-axis line chart with both axes and a dynamic legend based on slicers can be challenging because Power BI's native line chart visual currently has limitations in handling multiple dynamic Y-axes with legends. Here are a couple of approaches you could try:
1. Using Calculation Groups for Dynamic Measures
Here’s how you can implement it:
Step 1: Enable External ToolsTo create calculation groups, you need Tabular Editor, which is available as part of the external tools in Power BI Desktop. Ensure it is installed and enabled.
Step 2: Create Calculation Groups
Step 3: Return to Power BI
Step 4: Configure the Line Chart
Step 5: Handle Interaction Between Slicers and ChartEnsure that the slicers interact properly with the line chart:
Optional: Synchronize AxesIf needed, configure the Y-axes to use the same scale by setting Y-axis Start/End values manually in the Format pane.
TestingSelect different measures in the slicers and observe how the Y-axis values and lines on the chart update dynamically.
2. Custom Visuals for Enhanced Dual Y-Axis and Legend Control
Several custom visuals in the Power BI marketplace support dual Y-axes and allow for more flexibility with legends. Here are a few that might work well:
If I have resolved your question, please consider marking my post as a solution. Thank you!
Hi @grazitti_sapna
Thank you for taking your time to reply 🙂
I tried the solution you provided but unfortunately the solution dint work for me
Hi @as1195 ,
I made simple samples and you can check the results below:
SelectedPrimaryYValue =
SWITCH(
TRUE(),
SELECTEDVALUE('Parameter 2'[Parameter Order]) = 0, SUM('Table'[Percent]),
SELECTEDVALUE('Parameter 2'[Parameter Order]) = 1, SUM('Table'[Number])
)
SelectedSecondaryYValue =
SWITCH(
TRUE(),
SELECTEDVALUE('Parameter'[Parameter Order]) = 0, SUM('Table'[Sale]),
SELECTEDVALUE('Parameter'[Parameter Order]) = 1, SUM('Table'[Cost])
)
An attachment for your reference. Hope it helps!
Best regards,
Community Support Team_ Scott Chang
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
DynamicSales =
SWITCH(
TRUE(),
SELECTEDVALUE(Slicer[Type]) = "Sales", [Sales],
SELECTEDVALUE(Slicer[Type]) = "Volume", [SalesVolume]
)
💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 38 | |
| 36 | |
| 30 | |
| 28 |
| User | Count |
|---|---|
| 128 | |
| 88 | |
| 79 | |
| 67 | |
| 62 |