Forum Discussion
Switching columns based on slicer
Hi everyone,
I currently have a table called 'Flights', which contains one row per unique flight. The table contains different columns, including 'Origin Airport' and 'Destination Airport'. I would like to create a visualization showing the number of flights (Y-axis) per airport (X-axis). Instead of making two separate visualizations (one for origin airports and one for destination airports), I would like to combine both visualizations and let users decide if they want to see destination or origin airports based on a slicer. This basically means that the X-axis should use a different column based on the slicer selection. I have tried several solutions from both this forum and Google but every case I find seems to be a little bit different...
Thanks in advance!
For the moment, you cannot make dynamic X axis in Power BI because measures are still not accepted as axis (except in scatter charts).
You can use this trick though:
You pick a chart (let's say a histogram) with two columns in the X-Axis: The airport origin column and the destination column;
And then, you can play with the hierarchy of the graph to switch between origin and destination airports:
4 Replies
- DatatouilleSolution Sage
For the moment, you cannot make dynamic X axis in Power BI because measures are still not accepted as axis (except in scatter charts).
You can use this trick though:
You pick a chart (let's say a histogram) with two columns in the X-Axis: The airport origin column and the destination column;
And then, you can play with the hierarchy of the graph to switch between origin and destination airports:
- DatatouilleSolution Sage
Please accept as a solution so the whole community can benefit from our conversation and see it is actually solved :)
Thanks.
- FiejjRegular Visitor
Thanks, this will do for now. If anyone has a solution which allows for a 'real' slicer, please let me know. :)
- robofskiResolver II
This one got my creative side going as I have data like this so I wanted to see if there was a way around the limitation!
By creating summary tables and then using union to join the two summary tables together and a disconnected slicer I was able to achieve something that works!
Here's the pbix if you'd like to see how I went about it FlightDiary.pbix The data is pretty boring as I tend to flight from and to the same airports but you can see things change for some airports.