Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
cillepersille
Frequent Visitor

Conditional sorting with a filter

Hi!

I am currently working on a report that I want to be sorted based on a filter. 
The report shows train stops and capacity per each train stop along a trainroute (you can only filter by one route at a time). 
It is a line and stacked column diagram. 
The train can move two directions: D1 and D2, you can only filter by one of these at a time.
D1 goes from A to D and stops at station A, B, C, D
D2 goes from D to A and stops at station D, C, B, A
The train will stop along the same stations both ways, and here comes my problem:
Is there a way that when you select to filter it by D1, that the chart shows the order of the trainstops like this:
A, B, C, D, and then when you select to filter it by D2, it changes sorting to descending in the chart, and it puts D to the left in the X-axis and A to the right?

I have tried bookmarks and buttons, but it does not do the trick, as it also goes back to the filter that was applied in the bookmark. I want it to be a conditional sorting, so that when you chose to filter it by one of the directions, it changes, and not go back to the filter that was applied for the bookmark. 

Hope someone can help me 🙂

2 ACCEPTED SOLUTIONS
v-yalanwu-msft
Community Support
Community Support

Hi, @cillepersille ;

You could copy two identical Visuals, one ordered by A,B,C,D, and the other ordered by D,C,B,A. Then put it in a different place on a page; Then create a slicer, D1 and D2. And then measure it:

1.copy two visuals.

vyalanwumsft_0-1635746524274.png

2. enter the D1,D2 table.

vyalanwumsft_1-1635746607494.png

3.create a measure.

Measure = IF(MAX('slicer'[Slicer])="D1",1,0)

4.then apply it into filter.two Visuals one for 1 and one for 0.

vyalanwumsft_2-1635746717335.pngvyalanwumsft_3-1635746724301.png

The final output is shown below:

vyalanwumsft_4-1635746748616.png  vyalanwumsft_5-1635746758225.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

Thank you, @v-yalanwu-msft  !
This looks a lot like the solution I have currently ended up with, but I actually ended up putting the visual on two different pages in the report (one that I made invisible). What I ended up doing, was create a page called trains D1 and duplicated the page and called that D2. 

The D1 page is filtered by trains going in the D1 direction and the filter is locked, while the visual is sorted by descending. They are also only allowed to filter by one train route at a time. On the page there is a button that says "R2", and if they click there, they go to the next page, where the visual is sorted ascending, and the filter applied from page D1 stays on in page D2. 

It works very fine and it looks good 😄 

View solution in original post

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @cillepersille ;

I'm glad you found the right solution. Congratulations.Would you mind accept the helpful replies as solutions? Then we are able to close the thread. More people who have the same requirement will find the solution quickly and benefit here. Thank you!

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yalanwu-msft
Community Support
Community Support

Hi, @cillepersille ;

You could copy two identical Visuals, one ordered by A,B,C,D, and the other ordered by D,C,B,A. Then put it in a different place on a page; Then create a slicer, D1 and D2. And then measure it:

1.copy two visuals.

vyalanwumsft_0-1635746524274.png

2. enter the D1,D2 table.

vyalanwumsft_1-1635746607494.png

3.create a measure.

Measure = IF(MAX('slicer'[Slicer])="D1",1,0)

4.then apply it into filter.two Visuals one for 1 and one for 0.

vyalanwumsft_2-1635746717335.pngvyalanwumsft_3-1635746724301.png

The final output is shown below:

vyalanwumsft_4-1635746748616.png  vyalanwumsft_5-1635746758225.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thank you, @v-yalanwu-msft  !
This looks a lot like the solution I have currently ended up with, but I actually ended up putting the visual on two different pages in the report (one that I made invisible). What I ended up doing, was create a page called trains D1 and duplicated the page and called that D2. 

The D1 page is filtered by trains going in the D1 direction and the filter is locked, while the visual is sorted by descending. They are also only allowed to filter by one train route at a time. On the page there is a button that says "R2", and if they click there, they go to the next page, where the visual is sorted ascending, and the filter applied from page D1 stays on in page D2. 

It works very fine and it looks good 😄 

lbendlin
Super User
Super User

You cannot sort a column by a measure, only by another column ( in the same table!)

 

You can achieve your goal with a fully customized visual based on measures, with each measure representing a station slot, but where the first measure can represent A or D, the second B or C etc.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.

Top Solution Authors