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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Kotebe
New Member

How to Change the Bar graphs color to orange only when the 5 consecutive increments of the value?

How to Change the Bar graph's color to orange only when the 5 consecutive increments of the value? in power bi
I only changed the color from mar-toJulyy to orange the rest remain blue

Month

Value

Jan

200

Feb

250

Mar

180

Apr

280

May

290

Jun

300

July

350

Aug

150

Sep

179

Oct

800

Nov

200

Dec

400

6 REPLIES 6
v-xuxinyi-msft
Community Support
Community Support

Hi @Kotebe 

 

Thanks for the reply from Sahir_Maharaj .

 

The following measures are for your reference, I added an index column to your original data.

vxuxinyimsft_0-1733900550841.png

 

Consecutive Increments = 
VAR _CurrentIndex = MAX('Table'[Index])
VAR _CurrentValue = MAX('Table'[Value])
VAR _Prev1 = CALCULATE(MAX('Table'[Value]), FILTER(ALL('Table'), 'Table'[Index] = _CurrentIndex - 1))
VAR _Prev2 = CALCULATE(MAX('Table'[Value]), FILTER(ALL('Table'), 'Table'[Index] = _CurrentIndex - 2))
VAR _Prev3 = CALCULATE(MAX('Table'[Value]), FILTER(ALL('Table'), 'Table'[Index] = _CurrentIndex - 3))
VAR _Prev4 = CALCULATE(MAX('Table'[Value]), FILTER(ALL('Table'), 'Table'[Index] = _CurrentIndex - 4))
VAR _CheckIncrements =
    IF(_CurrentValue > _Prev1 && _Prev1 > _Prev2 && _Prev2 > _Prev3 && _Prev3 > _Prev4, 1, 0)
RETURN
    _CheckIncrements

 

Color = 
VAR _Index =
MAXX(FILTER(ALL('Table'), [Consecutive Increments] = 1), 'Table'[Index])
RETURN
IF(
    MAX('Table'[Index]) IN {_Index, _Index - 1, _Index - 2, _Index - 3, _Index - 4},
    "orange",
    "blue"
)

 

Then set the conditional format in format your visual -> Columns -> Color.

vxuxinyimsft_1-1733900819376.png

 

vxuxinyimsft_2-1733901263610.png

 

Output:

vxuxinyimsft_3-1733901290896.png

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This a summarized table, How can Like Order date in Table 1 and Date in Date table Product in Tabl1
The one above is only a summarized table from the Date table and Table1 if I add Product to the summarized table I the aggregation is not working 

Thank you 

 

Sahir_Maharaj
Super User
Super User

Hello @Kotebe,

 

Can you please try creating a calculated column to identify if a bar meets the condition:

Consecutive Increments =
VAR CurrentMonth = 'Table'[Month]
VAR CurrentValue = 'Table'[Value]
VAR PreviousValues =
    TOPN(
        5,
        FILTER(
            'Table',
            'Table'[Month] < CurrentMonth
        ),
        'Table'[Month], DESC
    )
VAR IsIncrement =
    IF(
        COUNTROWS(PreviousValues) = 5 &&
        MAXX(PreviousValues, 'Table'[Value]) < CurrentValue,
        TRUE(),
        FALSE()
    )
RETURN
IF(IsIncrement, "Orange", "Blue")

Then you can apply conditional formatting.

 

Hope this helps.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

These gives me all bar chart blue, even though it has orange section 

Have you test these code?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.