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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
gregtm
New Member

Count Rows in a column based on another column's distinct value

I want to total the Buyers in column B based on the PO in column A.  Example  1 PO = 3 buyers (Total column)  I have tried a couple of measures Distinctcount and Count but can't seem to get it.

POBuyerTotal
1001B3
1001C 
1001D 
1002A4
1002B 
1002C 
1002D 
1003B1
1004A1
1005A2
1005B 
1007A3
1007B 
1007C 
1008B1
1009B2
1009D 
1010A3
1010B 
1010C 
1011B2
1011D 
1012B1
1013A3
1013B 
1013C 
1020A3
1020B 
1020C 
1022A3
1022B 
1022C 
1 ACCEPTED SOLUTION
CoreyP
Solution Sage
Solution Sage

A measure like this should work:

Buyer Count per PO = CALCULATE( DISTINCTCOUNT( [Buyer] ) , ALLSELECTED( {Buyer] ) )
 
The reason for writing the measure this way is in your above example, you want the total number of buyers per PO within a table containing both PO and Buyer, so you need to remove the row context of Buyer from the calculation. This is what the ALLSELECTED here is doing.

View solution in original post

2 REPLIES 2
CoreyP
Solution Sage
Solution Sage

A measure like this should work:

Buyer Count per PO = CALCULATE( DISTINCTCOUNT( [Buyer] ) , ALLSELECTED( {Buyer] ) )
 
The reason for writing the measure this way is in your above example, you want the total number of buyers per PO within a table containing both PO and Buyer, so you need to remove the row context of Buyer from the calculation. This is what the ALLSELECTED here is doing.

Thank you very much.  That works perfectly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

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.