Forum Discussion

Nivedhana's avatar
Nivedhana
Helper I
2 years ago
Solved

Conditional font colour formatting based on predefined values from another table

We are working on a BI with multiple tables. There are 2 separate tables as seen below. The predefined values are stored in one table and actual values stored in another. We are using actual values i...
  • 123abc's avatar
    123abc
    2 years ago

    If there is no direct relationship or connection between the two tables based on parameters, you can still achieve conditional font color formatting by using a DAX (Data Analysis Expressions) measure that calculates whether the actual values are within the predefined ranges for each product and parameter combination. Here's how you can modify the approach:

    1. Create a DAX measure in your "Actual values" table that checks if the actual value for a specific product and parameter falls within the predefined range. You can use a measure like this:

    IsValueWithinRange =
    VAR CurrentProduct = 'Actual values'[Product]
    VAR CurrentParameter = 'Actual values'[Parameters]
    VAR ActualValue = 'Actual values'[Value]
    VAR PredefinedValue1 = CALCULATE(MAX('Predefined'[Value1]),
    FILTER('Predefined', 'Predefined'[Product] = CurrentProduct && 'Predefined'[Parameters] = CurrentParameter))
    VAR PredefinedValue2 = CALCULATE(MAX('Predefined'[Value2]),
    FILTER('Predefined', 'Predefined'[Product] = CurrentProduct && 'Predefined'[Parameters] = CurrentParameter))
    RETURN
    IF(ActualValue >= PredefinedValue1 && ActualValue <= PredefinedValue2, "Green", "Red")

     

    This measure calculates whether the actual value is within the predefined range for the current product and parameter combination. It returns "Green" if it is within the range and "Red" if it's not.

    1. Once you've created the DAX measure, you can use it in your matrix table to conditionally format the font color. Here's how you can do this:

      • Select the cell or text where you want to apply the font color formatting.
      • Go to the "Conditional formatting" option in your BI tool.
      • Choose "Font color."
      • Set up the formatting rules like this:
        • If the "IsValueWithinRange" measure equals "Red," set the font color to red.
        • If the "IsValueWithinRange" measure equals "Green," set the font color to green.
    2. Repeat steps 1 and 2 for each cell or text where you want to apply the conditional font color formatting in your matrix table.

    This approach uses a DAX measure to dynamically calculate whether the actual values are within the predefined ranges for each product and parameter combination. It doesn't rely on a direct relationship between the two tables based on parameters but instead leverages DAX calculations to determine the font color based on the data in both tables.