Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Conditional Formatting by comparing Two State Columns

Hi Team,   I have four colums Source Id and its State and Target ID and its State. I would like to achieve rollup of  targetID state and then color code the source Id (Title) to either Red or Green...
  • Icey's avatar
    Icey
    4 years ago

    Hi Anonymous ,

     

    Try to create a measure and set conditional formatting like so:

    Measure = 
    VAR SourceStates_ =
        VALUES ( 'Stage State'[Source State] )
    VAR CurSourceState_ =
        MAX ( Source[Source State] )
    VAR TargetStates_ =
        CALCULATETABLE (
            VALUES ( 'Stage State'[Target State] ),
            'Stage State'[Source State] = CurSourceState_
        )
    VAR CurTargetStates_ =
        CALCULATETABLE (
            VALUES ( Source[Target State] ),
            ALLEXCEPT ( Source, Source[Source ID], Source[Source State] )
        )
    VAR ExceptTargetStatesCount_ =
        COUNTROWS ( EXCEPT ( CurTargetStates_, TargetStates_ ) )
    RETURN
        IF ( CurSourceState_ IN SourceStates_ && ExceptTargetStatesCount_ = 0, "Green", "Red" )
    

     

    And Matrix visual can't set conditional formatting on fields on Rows or Columns.

     

     

    Best Regards,

    Icey

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.