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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors