Forum Discussion

VictoriaTomaz's avatar
VictoriaTomaz
Frequent Visitor
2 years ago
Solved

Display Count in Pie Chart based on Condition

Hello, I have some sample data here: ID Class 1 A 1 B 1 C 2 A 3 A 3 B 4 A 4 C   I'm trying to create a pie chart that displays a count of "Class" but I only ...
  • VictoriaTomaz's avatar
    2 years ago

    In case anyone happens to stumble upon this post with the same question, this is the dax I ended up writing to help me figure out this issue:

     

    Measure = 
    VAR A = CALCULATETABLE(DISTINCT(Table[ID], Table[Class] = "A")
    VAR B = CALCULATETABLE(DISTINCT(Table[ID], Table[Class] = "B")
    VAR AB = INTERSECT(A, B)

    RETURN
    CALCULATE(

    COUNTROWS(Table, Table[ID] IN AB)

     

    And then in the visual tab of the pie chart, put this measure under "Values" and put the Class column from the table under "Legend".