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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Fiala
Helper II
Helper II

count of values based on rank

Hi, can somebody help me with this please?

I have a table like this:

DateLoginN chatsRank (N chats)
1.1.2020A51
1.1.2020B42
1.1.2020C33
1.1.2020D24
1.2.2020A61
1.2.2020B52
1.2.2020C43
1.2.2020D34
1.3.2020A91
1.3.2020B52
1.3.2020C43

 

Rank funkcion ranks me all values ​​for all days together, not separately for each day.

I need create a matrix with logins and date in rows and with the measure "count logins with rank = 1":

LoginCount  Rank = 1
A3
B0
C0

 

My attempts so far are failing, it seems like a simple task, but I can't move on. Thank you for all the help.




 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @Fiala 

Please check the below picture and the sample pbix file's link down below.

 

Picture1.png

 

Rank N chats per day =
IF (
ISFILTERED ( 'Table' ),
RANKX (
ALLEXCEPT ( 'Table', 'Table'[Date] ),
CALCULATE ( SUM ( 'Table'[N chats] ) ),
,
DESC
)
)
 
 
Count Rank No.1 =
VAR currentlogin =
MAX ( 'Table'[Login] )
VAR newtable =
FILTER (
SUMMARIZE (
ALL ( 'Table' ),
'Table'[Date],
'Table'[Login],
"@rank", [Rank N chats per day]
),
[@rank] = 1
)
RETURN
IF(
ISFILTERED('Table'[Login]),
COALESCE ( COUNTROWS ( FILTER ( newtable, 'Table'[Login] = currentlogin ) ), 0 ))
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

5 REPLIES 5
Fiala
Helper II
Helper II

@Jihwan_Kim I think I got it, I only slightly adjusted your measure. Thank you very much.

Fiala
Helper II
Helper II

@Jihwan_Kim Thank you very much. 

In general it works great. But what if I also need to work with the date and see how many times the login "A" was rank 1 in January or last week? The measure seems to ignore the dates and returns the same results every month.

Hi, @Fiala 

Thank you for your feedback.

Sorry that I quite do not understand your question.

In the initial question, the row is showing the date. Do you want to change this to week or month?

Then, simply you can fix the measure to consider the overall calendar.

 

Or, please share your sample pbix file's link here, together with how your desired outcome looks like.

Then, I can try to look into it to come up with a more accurate measure.

Thanks.

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
CNENFRNL
Community Champion
Community Champion

Calculated column solution,

Screenshot 2021-05-19 220739.png

Screenshot 2021-05-19 220846.png

 

Measure solution

Screenshot 2021-05-19 221002.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Jihwan_Kim
Super User
Super User

Hi, @Fiala 

Please check the below picture and the sample pbix file's link down below.

 

Picture1.png

 

Rank N chats per day =
IF (
ISFILTERED ( 'Table' ),
RANKX (
ALLEXCEPT ( 'Table', 'Table'[Date] ),
CALCULATE ( SUM ( 'Table'[N chats] ) ),
,
DESC
)
)
 
 
Count Rank No.1 =
VAR currentlogin =
MAX ( 'Table'[Login] )
VAR newtable =
FILTER (
SUMMARIZE (
ALL ( 'Table' ),
'Table'[Date],
'Table'[Login],
"@rank", [Rank N chats per day]
),
[@rank] = 1
)
RETURN
IF(
ISFILTERED('Table'[Login]),
COALESCE ( COUNTROWS ( FILTER ( newtable, 'Table'[Login] = currentlogin ) ), 0 ))
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.