Forum Discussion

jakubw's avatar
jakubw
Regular Visitor
6 years ago
Solved

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!

  • 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])

    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’.

    Result:

    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.

1 Reply

  • v-alq-msft's avatar
    v-alq-msft
    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])

    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’.

    Result:

    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.