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.
Justas4478 , You will need to create a measure and use that in conditional formatiing
DAX
PreviousValue =
CALCULATE(
MAX('Table'[Value]),
FILTER(
'Table',
'Table'[Month] = EARLIER('Table'[Month]) &&
'Table'[Year] = EARLIER('Table'[Year]) &&
'Table'[Date] < EARLIER('Table'[Date])
)
)
ValueChange =
IF(
ISBLANK([PreviousValue]),
BLANK(),
IF(
[Value] > [PreviousValue],
"Green",
IF(
[Value] < [PreviousValue],
"Red",
"Yellow"
)
)
)
Use the ValueChange measure to apply the conditional formatting rules in the "Advanced controls" section.
https://www.youtube.com/watch?v=wTRrskQzAHk- go through this for more in depth
bhanu_gautam I tried creatign the emasure but for some reason it does not want to find my date table and columns.
This is what I get.