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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
ddalton
Resolver I
Resolver I

Find most common text value with criteria

In Excel, I'm able to find the most common text value in a Table column based on criteria using the following expression (table provided as a representation):

 

Table

ID (Column A)Class (Column B)Value (Column C)
001ARed/A
002BRed/B
003CBlue/C
004CRed/C
005ARed/A
006AGreen/A
007BBlue/B

 

Generic Expression

= INDEX(range, MODE(IF(logical, MATCH(range, rage, 0) 

Specific Expression (in this case, looking for the most common Text value in column C (Value) that matches the Class with "A")

= INDEX('Table'!C:C,MODE(IF('Table'!B:B="A",MATCH('Table'!C:C,'Table'!C:C,0))))

 

In the example above, the cell with that expression in it would return Red/A since that's most common Value value for Class A in the Table. 

 

Is it possible to do something similar in Power BI (i.e., create a measure) and display the value in a Card visualisation? I cannot figure out how to translate this into a DAX expression that I can use in Power BI. 

1 ACCEPTED SOLUTION
AntonioM
Solution Sage
Solution Sage

If you only ever need the top one value, you could try

 

measure = 

VAR _table =
    SUMMARIZE (
        'Table',
        'Table'[Class],
        'Table'[Value],
        "count"DISTINCTCOUNT ( 'Table'[ID] )
    )
VAR maxcount =
    MAXX ( _table, [count] )
RETURN
    CALCULATE (
        SELECTEDVALUE ( 'Table'[Value] ),
        FILTER ( _table, [count] = maxcount )
    )

 

 

Which will give you "Red/A" for A, but blank for B and C (as there is not one most common value).

AntonioM_2-1658498221991.png

 

To use it in a card, you would need to filter the card with Table[Class], to see the most common for specifically A, B or C. You could also include the filter in a measure

 

 measure A = CALCULATE ( [measure], Table[Class] = "A" ) 

 

 

If you want to see the most common values which tie with each other (such as for B and C), then you can replace the  SELECTEDVALUE ( 'Table'[Value] ) with  CONCATENATEX(VALUES('Table'[Value]), 'Table'[Value], " ") 

 

AntonioM_1-1658498193864.png

 

 

 

View solution in original post

3 REPLIES 3
v-henryk-mstf
Community Support
Community Support

Hi @ddalton ,

 

Whether the advice given by @AntonioM  has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.


Looking forward to your feedback.


Best Regards,
Henry

AntonioM
Solution Sage
Solution Sage

If you only ever need the top one value, you could try

 

measure = 

VAR _table =
    SUMMARIZE (
        'Table',
        'Table'[Class],
        'Table'[Value],
        "count"DISTINCTCOUNT ( 'Table'[ID] )
    )
VAR maxcount =
    MAXX ( _table, [count] )
RETURN
    CALCULATE (
        SELECTEDVALUE ( 'Table'[Value] ),
        FILTER ( _table, [count] = maxcount )
    )

 

 

Which will give you "Red/A" for A, but blank for B and C (as there is not one most common value).

AntonioM_2-1658498221991.png

 

To use it in a card, you would need to filter the card with Table[Class], to see the most common for specifically A, B or C. You could also include the filter in a measure

 

 measure A = CALCULATE ( [measure], Table[Class] = "A" ) 

 

 

If you want to see the most common values which tie with each other (such as for B and C), then you can replace the  SELECTEDVALUE ( 'Table'[Value] ) with  CONCATENATEX(VALUES('Table'[Value]), 'Table'[Value], " ") 

 

AntonioM_1-1658498193864.png

 

 

 

Thanks. I'll give this a try. The real data will rarely (if ever) have a scenario where the number of Column C values are the same so your solution should always return a value. 

 

I'll try it, and update/accept the solution if it works out for me.  

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Solution Authors