Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AGo
Post Patron
Post Patron

Bar-chart conditional formatting

In the new format pane of the new version I can no longer find the Conditional formatting option for bar chart.

Is there a way to format the bar color in some way (dax maybe)? I've got x-axis=month, legenda=year, y-axis=revenues: I'd like to simply filter only last two years and show current year bar in red if the revenue is lower than previous year.

 

Thanks for support!

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

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.

vstephenmsft_1-1650875343909.png

vstephenmsft_0-1650875228084.png

 

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.

View solution in original post

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

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.

vstephenmsft_1-1650875343909.png

vstephenmsft_0-1650875228084.png

 

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.