Forum Discussion

kenyaherring93's avatar
8 months ago
Solved

Conditional Formatting with Matrix Table

Hi! I am want to set up my matrix table so that when someone expands on a training course in my table the user will see a check icon if the course is completed and an "X" icon if the course is not co...
  • Zanqueta's avatar
    Zanqueta
    8 months ago

    Hello djurecic,

     

    Sorry but I initially misunderstood your requirement, assuming you only needed icons at the user level. The measure you shared changes the DAX logic because it now combines two behaviours: displaying icons for individual users and showing aggregated counts for totals. This requires context evaluation using HASONEVALUE() to distinguish between detail and subtotal levels

     

    The approach works correctly, but note:
    • It behaves differently from the original icon-only measure.
    • You will need to adapt table and column names (e.g., Query4) to match your data model.

     

    Status Icon or Count = 
    VAR CompletedFlag = SELECTEDVALUE(Query4[Completed], 0)
    VAR NotCompletedFlag = SELECTEDVALUE(Query4[NotCompleted], 0)
    VAR CountCompleted = CALCULATE(COUNTROWS(Query4), Query4[Completed] = 1)
    VAR CountNotCompleted = CALCULATE(COUNTROWS(Query4), Query4[NotCompleted] = 1)
    RETURN
    SWITCH(
        TRUE(),
           HASONEVALUE(Query4[User]),
            SWITCH(
                TRUE(),
                CompletedFlag = 1, "✔",
                NotCompletedFlag = 1, "✖",
                BLANK()
            ),
        // Caso seja subtotal (mais de um utilizador)
        CountCompleted & " Completed | " & CountNotCompleted & " Not Completed"
    )

     

     

    If this response was helpful in any way, I’d gladly accept a 👍much like the joy of seeing a DAX measure work first time without needing another FILTER.

    Please mark it as the correct solution. It helps other community members find their way faster (and saves them from another endless loop 🌀.