Forum Discussion
Nested IF - dates
- 4 years ago
PC2022 , Create a new column like
=
var _diff = datediff([finish date], today(), day)
return
Switch(True(),
_diff >=45 , "Green",
_diff > 0 , "Yellow",
"Red"
)
you can use this column in conditional formatting using the field value option
- Anonymous4 years ago
Hi PC2022,
In fact, you can use one calculated column to achieve these, you only need to add a variable to store the first step result and use the switch function to check the diff and return color code.
Color code = VAR _diff = DATEDIFF ( [finish date], TODAY (), DAY ) RETURN SWITCH ( TRUE (), _diff >= 45, "Green", _diff > 0, "Yellow", "Red" )After these steps, you can right-click on your field that needs to be formatted with 'field value' mode based on the above 'color code' column field values.
Apply conditional table formatting in Power BI - Power BI | Microsoft Docs
Regards,
Xiaoxin Sheng
Thank you! Sorry, I am new to Power BI and a little confused on your answer:
Do you mean to create 2 columns?
1)
2)
Hi PC2022,
In fact, you can use one calculated column to achieve these, you only need to add a variable to store the first step result and use the switch function to check the diff and return color code.
Color code =
VAR _diff =
DATEDIFF ( [finish date], TODAY (), DAY )
RETURN
SWITCH ( TRUE (), _diff >= 45, "Green", _diff > 0, "Yellow", "Red" )
After these steps, you can right-click on your field that needs to be formatted with 'field value' mode based on the above 'color code' column field values.
Apply conditional table formatting in Power BI - Power BI | Microsoft Docs
Regards,
Xiaoxin Sheng