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
Anonymous
Not applicable

How to get number of occurrences of a value, defined in another measure?

Here is the data: 

let
    Source = #table({"Status"},List.Zip({{"ON","OFF","UNKNOWN","ON","ON","OFF"}})),
    #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type)
in
    #"Added Index"

I need a measure which returns the number of occurrences of the most frequently occurring value in the "Status" column. So in this example, "ON" appears the most, and it occurs 3 times. 

 

I have a measure which correctly identified the most frequently occurring value: 

 

most repeated status = MAXX(TOPN(1, GROUPBY(Query1, Query1[Status], "Count",COUNTX(CURRENTGROUP(), Query1[Status])), [Count], DESC), [Status] )
 
I then try to take the value from 'most repeated status' and feed it into a filter function, to filter my table column for rows which contain that value, so that I can count how many times the value occurs.
 
I've tried various iterations of something like this:
 
Measure 5 = CALCULATE(DISTINCTCOUNT(Query1[Index]), Query1[Status] = [most repeated status])
 
another example: 
 
Measure 2 = CALCULATE(COUNT(Query1[Status]), FILTER(Query1, Query1[Status] = [most repeated status]))

 

but none of the above are correct. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

found the solution:

 

count of most repeated status = VAR higheststatus = [most repeated status] RETURN CALCULATE(COUNT(Query1[Status]),FILTER(Query1, Query1[Status] = higheststatus))

View solution in original post

1 REPLY 1
Anonymous
Not applicable

found the solution:

 

count of most repeated status = VAR higheststatus = [most repeated status] RETURN CALCULATE(COUNT(Query1[Status]),FILTER(Query1, Query1[Status] = higheststatus))

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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