The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hey Community!
I have those two tables:
I want to get the movie with the highest ROI for each Major Genre and show the Director's name of the film.
The tables are related by column name "Title".
I tried to rank by group (Genre) that will be ordered descending by ROI to get all the 1's, but it didn't work.
Where did I go wrong?
Here's the DAX code:
Rank Genre =
RANKX(ALLEXCEPT(Movie_Details, Movie_Details[Major Genre]),MAXX(RELATEDTABLE(Revenue),Revenue[ROI]),,DESC)
And here's an example of the ranking for the genre "Action" with descending ROI:
Solved! Go to Solution.
DEFINE
MEASURE ROIs[Total ROI] = sum(ROIs[ROI] )
MEASURE Films[Rank by ROI] =
if ( ISINSCOPE(Films[Title] ),
var CurrentGenre = SELECTEDVALUE( Films[Genre] )
var RankWithinGenre =
RANKX(
FILTER(
ALLSELECTED( Films ),
Films[Genre] = CurrentGenre
),
[Total ROI]
)
return
RankWithinGenre
)
DEFINE
MEASURE ROIs[Total ROI] = sum(ROIs[ROI] )
MEASURE Films[Rank by ROI] =
if ( ISINSCOPE(Films[Title] ),
var CurrentGenre = SELECTEDVALUE( Films[Genre] )
var RankWithinGenre =
RANKX(
FILTER(
ALLSELECTED( Films ),
Films[Genre] = CurrentGenre
),
[Total ROI]
)
return
RankWithinGenre
)
Thanks! it works great!
User | Count |
---|---|
24 | |
10 | |
8 | |
6 | |
5 |
User | Count |
---|---|
31 | |
12 | |
10 | |
10 | |
9 |