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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Kotebe
Helper I
Helper I

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

15 REPLIES 15
Kotebe
Helper I
Helper I

it only works for some particular year if the year changes does not work

Anonymous
Not applicable

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.

What about If I added Product Family as a filter and ignore one out lier ?

What would be if there is one outlier  can be considerd as Trend

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 March to orange the rest remain blue

Month Value if the value which is an outlier it should be considered  

Jan

200

Feb

250

Mar

180

Apr

280

May

290

Jun

300

July

350

Aug

150

Sep

179

Oct

800

Nov

200

Dec

400

If you add a month it will not work , indexing working for only 12 month  if it is 24 month Indexing will not work, Can you show me how it work indexing for Jan-2023 and Jan-2024-, jan-2025.... ?

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 

Anonymous
Not applicable

Hi @Kotebe 

 

Do you mean that the Month and Value columns come from two tables? If so, could you please provide some sample data from both tables so that we can help you better? How to provide sample data in the Power BI Forum - Microsoft Fabric Community Or show them as screenshots or pbix. Please remove any sensitive data in advance. If uploading pbix files please do not log into your account. 

 

Best Regards,
Yulia Xu

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
➤ About: https://sahirmaharaj.com/about.html
➤ 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

What about I added Product family as a filter content and based on that and ignore one outlier and shous as a green for consecuative increment

Lets take the lasst 6 month consecuative month increment with one outlier , which means if the Value increase consequatively even if we have one outlier we can say a trend , other wise if not consecuative increment , we can say not a trend 

What DAX code handle these scenario

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

Have you test these code?

How do Mangae the Outlier of the 5 month Consecuetive increment   of highlighted with Orange color ?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors