Forum Discussion

kekepania0529's avatar
4 years ago
Solved

Conditional Formatting based on 2 columns - 1 numeric and 1 text

I need to format the background and text colors based on 2 columns. 1 is a numeric column and 1 is a text column. In excel the conditional formatting formula would be:  =AND($Q1<Value,LEFT($I1,3)="...
  • timg's avatar
    4 years ago

    Hi,

    In this case you could add a column or measure containing the the colour code you would like to assign with conditional formatting (a measure would be preferable if the condition depends on the aggregation, a calculated column would be preferable if every row of your table should get a colour assigned). Below you will find an example of a file with a calculated column and measure that assign a colour code when conditions are met. By adding conditional formatting based on a field value (select the visual > consitional formatting > advanced controls > format by: field value ) you make the visual apply this colour based on the result in the measure or calculated column.

     

    Measure example:

    Colour =
    IF (
        AND ( SUM ( 'Table'[Value] ) > 20, SUM ( 'Table'[Value] ) < 60 ),
        "#FF0000",
        BLANK ()
    )
    

    Column example: 

    ColumnColour =
    IF (
        AND ( 'Table'[Value] = 10, 'Table'[Category] = "Category A" ),
        "#00FF00",
        BLANK ()
    )
    

    Result:

     

    Best regards,

     

    Tim