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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.