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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
jakubw
Regular Visitor

Sort a slicer by a dynamically generated measure

I have a problem with sorting a slicer in Power BI desktop.

 

Let's say I have a table with movies, that feeds the slicer in question.

 

movies:

TitleBox officeYear
Avengers: Endgame $2,797,800,5642019
 Avatar$2,789,958,5072009
Titanic $2,187,463,9441997
 Star Wars: The Force Awakens$2,068,223,6242015
 Avengers: Infinity War$2,048,359,7542018

 

And another table with their ratings, related by the Title column:


ratings:

TitleSiteRating
Avengers: Endgame Metacritic78%
Avengers: Endgame Rotten Tomatoes94%
Avengers: Endgame IMDB85%
TitanicRotten Tomatoes92%
TitanicIMDB91%

 

I want to sort the movies by average rating from chosen services.

 

I tried to make a measure like AvgRating = AVERAGE(ratings[Rating]), and it computes exactly what I wanted, but you cannot sort a slicer by measure.
I also tried making a calculated column in the movies table: AvgRating = AVERAGE(ratings[Rating]), so I can use the "sort by column" option. However, calculated columns in PBI are only refreshed on data load, so the results do not change when I choose different services.

Is there any option to do this kind of thing, or am I doomed?

 

Thanks in advance!

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi,

Based on your description, I created data to reproduce the scenario. ‘AvgRatings’ is a column. ‘AvgRating’ is a measure.

 

AvgRatings = CALCULATE(AVERAGE(ratings[Rating]),RELATEDTABLE(ratings))

 

AvgRating = AVERAGE(ratings[Rating])

a.png

It is unavailable to sort a slicer by measure. As a workaround, you can use the ‘Hierarchical Filter - xViz’ visual from Marketplace and use ‘AvgRating’ measure as value. And in the ‘Fields’, click the ‘drop down’ button and choose ‘show item with no data’.

b.png

Result:

d1.png

If I misunderstand your thought, please show me your expected output, I am glad to solve the problem for you.

 

Best Regards,

Allan

 

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

1 REPLY 1
v-alq-msft
Community Support
Community Support

Hi,

Based on your description, I created data to reproduce the scenario. ‘AvgRatings’ is a column. ‘AvgRating’ is a measure.

 

AvgRatings = CALCULATE(AVERAGE(ratings[Rating]),RELATEDTABLE(ratings))

 

AvgRating = AVERAGE(ratings[Rating])

a.png

It is unavailable to sort a slicer by measure. As a workaround, you can use the ‘Hierarchical Filter - xViz’ visual from Marketplace and use ‘AvgRating’ measure as value. And in the ‘Fields’, click the ‘drop down’ button and choose ‘show item with no data’.

b.png

Result:

d1.png

If I misunderstand your thought, please show me your expected output, I am glad to solve the problem for you.

 

Best Regards,

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors