Forum Discussion
Bar-chart conditional formatting
- Anonymous4 years ago
Hi AGo ,
If you have something in the legend field, you cannot use formatting.
It is suggested to put year and month into x-axis and set color.
You could create a measure like
Color = VAR _currentyear = CALCULATE ( SUM ( 'Table'[revenues] ), FILTER ( ALLSELECTED ( 'Table' ), [month] = MAX ( 'Table'[month] ) && [year] = MAX ( 'Table'[year] ) ) ) VAR _lastyear = CALCULATE ( SUM ( 'Table'[revenues] ), FILTER ( ALLSELECTED ( 'Table' ), [month] = MAX ( 'Table'[month] ) && [year] = MAX ( 'Table'[year] ) - 1 ) ) RETURN IF ( _currentyear < _lastyear, "red" )Then add the measure into data colors.
You could check more details from my attachment.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi AGo ,
If you have something in the legend field, you cannot use formatting.
It is suggested to put year and month into x-axis and set color.
You could create a measure like
Color =
VAR _currentyear =
CALCULATE (
SUM ( 'Table'[revenues] ),
FILTER (
ALLSELECTED ( 'Table' ),
[month] = MAX ( 'Table'[month] )
&& [year] = MAX ( 'Table'[year] )
)
)
VAR _lastyear =
CALCULATE (
SUM ( 'Table'[revenues] ),
FILTER (
ALLSELECTED ( 'Table' ),
[month] = MAX ( 'Table'[month] )
&& [year]
= MAX ( 'Table'[year] ) - 1
)
)
RETURN
IF ( _currentyear < _lastyear, "red" )
Then add the measure into data colors.
You could check more details from my attachment.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Hello,
- What if I will be having continous 12 months. Just need to apply conditional formatting to all months in same bar chart.
- Because the previous answer is not working