Forum Discussion
Custom conditional formatting
- 1 year ago
Hi Justas4478
What exactly do you mean by the latest value for each month? So, if the most recent date with a value in December is the 31st and that value is 1, would you use that value? Then, would you compare it with the corresponding value from the previous month?
If you simply want the compare the value of this vs previous months value, try:
Conditional formatting color = VAR _PrevMonth = CALCULATE ( [my measure], PREVIOUSMONTH ( datestable[date] ) ) VAR _Difference = [my measure] - _PrevMonth VAR _Color = IF ( NOT ( ISBLANK ( _PrevMonth ) ) && NOT ( ISBLANK ( [my measure] ) ), IF ( _difference > 0, "green", IF ( difference < 0, "red" ) ) ) RETURN _ColorSelect field value from conditional formatting option and use the measure above. You may replace red or green with RGB, RGBA or hexadecimal values.
Hi Justas4478
What exactly do you mean by the latest value for each month? So, if the most recent date with a value in December is the 31st and that value is 1, would you use that value? Then, would you compare it with the corresponding value from the previous month?
If you simply want the compare the value of this vs previous months value, try:
Conditional formatting color =
VAR _PrevMonth =
CALCULATE ( [my measure], PREVIOUSMONTH ( datestable[date] ) )
VAR _Difference = [my measure] - _PrevMonth
VAR _Color =
IF (
NOT ( ISBLANK ( _PrevMonth ) ) && NOT ( ISBLANK ( [my measure] ) ),
IF ( _difference > 0, "green", IF ( difference < 0, "red" ) )
)
RETURN
_Color
Select field value from conditional formatting option and use the measure above. You may replace red or green with RGB, RGBA or hexadecimal values.
danextian I added additional IF statment to this part of dax to capture if value is = for sameperiodlastyear.
It looks to be working, but could you quickly check did I add it in correct part of dax code?