Forum Discussion
Request to Implement XY Plot with Dynamic Axis Filters
XY Plot Requirement
I need to build an XY plot and I have filters for both X-name and Y-name, where the values are the same.
Expectation:
- When the X-name filter is applied, the X-axis should automatically arrange values from minimum to maximum.
- Similarly, when the Y-name filter is applied, the Y-axis should also auto-arrange from minimum to maximum.
Data Columns: name, value
Conditions:
- The X-name filter should be single-select.
- The Y-name filter should be multi-select.
Hi ribisht17 ,
Sorry for the late response.
Please find the below snap and attached PBIX file.
If my response has resolved your query, please mark it as the "Accepted Solution" to assist others. Additionally, a "Kudos" would be appreciated if you found my response helpful.
Thank you
7 Replies
- v-dineshyaCommunity Support
Hi SSSBI ,
Thank you for reaching out to the Microsoft Community Forum.
Please follow below steps.
1. Create Parameters / Slicers:
X-name Slicer: Create a slicer visual. Use the name column. Set single-select ON.
Y-name Slicer: Create another slicer visual. Use the name column. Set multi-select ON.
2. Create Supporting Measures / Tables:
a. Create a Filtered Table for X-Axis
X_Values =
VAR SelectedX = SELECTEDVALUE('Table'[name])
RETURN
FILTER(
'Table',
'Table'[name] = SelectedX
)b. Create a Filtered Table for Y-Axis
Y_Values =
VAR SelectedY = VALUES('Table'[name])
RETURN
FILTER(
'Table',
'Table'[name] IN SelectedY
)3. Build a Combined Table for XY Plot: To pair values by index or row number, add row numbers first.
a. Add Indexes per Name: Use Power Query to group by name, then add an index per group.
b. Create a Combined Table:
XY_Combined =
VAR XName = SELECTEDVALUE('Table'[name])
VAR XTable =
ADDCOLUMNS(
FILTER('Table', 'Table'[name] = XName),
"Index", RANKX(FILTER('Table', 'Table'[name] = XName), 'Table'[value], , ASC)
)VAR YNames = VALUES('Table'[name])
VAR YTable =
ADDCOLUMNS(
FILTER('Table', 'Table'[name] IN YNames),
"Index", RANKX(FILTER('Table', 'Table'[name] IN YNames), 'Table'[value], , ASC)
)RETURN
SELECTCOLUMNS(
NATURALINNERJOIN(XTable, YTable),
"X", XTable[value],
"Y", YTable[value]
)4. Create the XY Scatter Plot
Use the final XY_Combined table.X-axis → X & Y-axis → Y. This will plot filtered values based on slicer selections. Axis will auto-scale due to default Power BI behavior (based on data range).
If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.
Thank you- ribisht17Super User
Can you share the PBIX file ?
- v-dineshyaCommunity Support
Hi ribisht17 ,
Sorry for the late response.
Please find the below snap and attached PBIX file.
If my response has resolved your query, please mark it as the "Accepted Solution" to assist others. Additionally, a "Kudos" would be appreciated if you found my response helpful.
Thank you
- v-dineshyaCommunity Support
Hi SSSBI ,
If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.
Thank you- v-dineshyaCommunity Support
Hi @SSSBI ,
If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.
Thank you
- ribisht17Super User
Hello SSSBI
X_Rank = RANKX(ALLSELECTED('Table'), 'Table'[Value], , ASC, DENSE)
Y_Rank = RANKX(ALLSELECTED('Table'), 'Table'[Value], , ASC, DENSE)
In this video you can find 3 ways > 3+ approaches for Dynamic Axis in Power BI - YouTube
You can see a similar Solution here > Single scatter chart w/ dynamic XY axis - Microsoft Fabric Community
Regards,
Ritesh
Community Champion
Please mark the answer if helpful so that it can help others