Forum Discussion
Conditional font colour formatting based on predefined values from another table
- 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:
- 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.
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.
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.
Hi,
Thanks! Can you please explain the data modelling part? Now both the tables are connected only by product details. There is no connection between the parameters
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:
- 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.
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.
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.
- Nivedhana2 years agoHelper I
Thank you very much! It worked!!
- 123abc2 years agoCommunity Champion
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
- Nivedhana2 years agoHelper I
Hi 123abc ,
In additional to the above condition, for some fileds, the condition is taking from another field in parameter. For ex, for parameter B for TV, the red highlight is based on parameter D value of TV and which check if D is within Predefined values
- Nivedhana2 years agoHelper I
Hi 123abc ,
Did you get a chance to check this? After implemeting the above case, we found out that for a few parameters, the colour code is based on other parameters. For example, for Mobile parameter A is coloured red if value of parameter B is not in range of predefined value B. I tried by myself to do this but unable to do it. Could you please assist?