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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
TooOld
Frequent Visitor

Ranking issue

Hi

I'm working on a result report on sport activities. Data source is a sql server database.

The report shall show results in a table based on field parameter slicer
Ranking 
- Daily
- Weekly
-Monthly
- Yearly

The overall ranking result is workung well, as I calculate the ranking in sql server queries and those shall be always visible independent on any filter set

Problem
I created a measure 'mRankOnFilterActyVolts', which shall create a sub ranking based on filter 
- Gender
- Nation
- ....

My problem is, that I only want to see the best result from the users based on TotalCalculatedPower. 

Actually I stuck on getting the max value in the context of a week, month, year


Measure

mRankOnFilterActyVolts =
IF(
HASONEVALUE(RfvRefined[TotalCalculatedPower]),
//var maxVolts = MAX(RfvRefined[TotalCalculatedPower])
 
var LookupTable =
ADDCOLUMNS(
ALLSELECTED(RfvRefined),
"@sumVolts", RfvRefined[TotalCalculatedPower]
)
 
var currentValue = SELECTEDVALUE(RfvRefined[TotalCalculatedPower])
var Result =
RANKX (LookupTable, [@sumVolts] , currentValue)
RETURN
Result
)

 

I suspect the 'ALLSELECTED'  but have actually no idea how to solve it




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

Hi @TooOld ,

 

I am not sure if I understood your question correctly. Are you trying to sort the maximum TotalCalculatedPower value for each user?

 

_max = 
CALCULATE (
    MAX ( RfvRefined[TotalCalculatedPower] ),
    ALLSELECTED ( RfvRefined ),
    VALUES ( RfvRefined[UserName] )
)
mRank2 = 
RANKX ( ALLSELECTED ( RfvRefined ), [_max],, DESC, DENSE )

vkkfmsft_0-1655801737099.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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

3 REPLIES 3
v-kkf-msft
Community Support
Community Support

Hi @TooOld ,

 

I am not sure if I understood your question correctly. Are you trying to sort the maximum TotalCalculatedPower value for each user?

 

_max = 
CALCULATE (
    MAX ( RfvRefined[TotalCalculatedPower] ),
    ALLSELECTED ( RfvRefined ),
    VALUES ( RfvRefined[UserName] )
)
mRank2 = 
RANKX ( ALLSELECTED ( RfvRefined ), [_max],, DESC, DENSE )

vkkfmsft_0-1655801737099.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello v-kkf-msft

your answer helps a lot. Dynamically it works very well. The only issue open is I'd like to add also the Challenge attribute to the table visual. When I do it, then your solution breaks.
I have to learn more about filter and context transition

lbendlin
Super User
Super User

Buckle up for a wild ride:  Use of RANKX in Power BI measures - SQLBI

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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