Forum Discussion

Astudham's avatar
Astudham
New Member
1 year ago
Solved

Distinct count in one column depending on the data in another column

I am looking to get a distinct count of a column based on data in another column see example below.  I want to get a count of Shapes but only counting 1 for each unique Color.  Where the example belo...
  • ArwaAldoud's avatar
    1 year ago

    Hi Astudham ,

    I tried DAX formula on a similar dataset for calculating the distinct count of shapes per color:
    Shape Count =
    CALCULATE(
    DISTINCTCOUNT('Table'[Shape]),
    ALLEXCEPT('Table', 'Table'[Color])
    )

    Here’s the dataset I used:

    | Color | Shape |
    | Red | Square |
    | Red | Square |
    | Blue | Square |
    | Green | Square |
    | Green | Circle |
    | Red | Circle |

     

    I got the following output:
    | Color | ShapeCount |
    | Red | 2 |
    | Blue | 1 |
    | Green | 2 |

    If this response was helpful, please accept it as a solution and give kudos to help others in the community.