Forum Discussion

gregtm's avatar
gregtm
New Member
2 years ago
Solved

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. P...
  • CoreyP's avatar
    2 years ago

    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.