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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Chirag4370
Helper I
Helper I

Conditional Formatting based on X-axis Value using DAX

Hello Experts, @MFelix

I need help to highlight column of Latest Month.

means change column color based on X-axis Values dynamically.

highlite column with selected color where date/month in X-axis is latest/max. below SS is desired result.

Chirag4370_0-1721298594145.png

I have written below DAX and applied to column color but it changes all bar color with latest.

LatestMonthColumnColor =
VAR maxMonth = CALCULATE( max(CycleDayUnpivot[EndDate1stOfMonth]), ALL(CycleDayUnpivot))
RETURN IF(MAX(CycleDays[EndDate1stOfMonth])=maxMonth, "#EE9771")

 

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@Chirag4370 , Create one measure for Latest Month

LatestMonth = CALCULATE(MAX(CycleDayUnpivot[EndDate1stOfMonth]), ALL(CycleDayUnpivot))

 

And trying updating second measure

 

LatestMonthColumnColor =
VAR maxMonth = [LatestMonth]
RETURN IF(MAX(CycleDays[EndDate1stOfMonth]) = maxMonth, "#EE9771", "#DefaultColor")




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

4 REPLIES 4
Chirag4370
Helper I
Helper I

Thank You @bhanu_gautam @bchager6 @fahadqadir3

got it.

Anonymous
Not applicable

@Chirag4370 Did you add your measure to the conditional formatting of the column color in the format pane?

 

fahadqadir3
Solution Supplier
Solution Supplier

@Chirag4370  Review the following attached screenshot and DAX formula:

fahadqadir3_0-1721301301593.png

LatestMonth = 
CALCULATE(
MAX('financials'[Date]),
ALL('financials')
)

 

fahadqadir3_1-1721301379150.png

IsLatestMonth = 
VAR LatestMonth = MONTH([LatestMonth])
VAR LatestYear = YEAR([LatestMonth])
VAR CurrentMonth = MONTH(MAX('financials'[Date]))
VAR CurrentYear = YEAR(MAX('financials'[Date]))
RETURN
IF(CurrentMonth = LatestMonth && CurrentYear = LatestYear, 1, 0)

fahadqadir3_2-1721301484841.png

@Chirag4370  Hope it works.

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!! 

 

bhanu_gautam
Super User
Super User

@Chirag4370 , Create one measure for Latest Month

LatestMonth = CALCULATE(MAX(CycleDayUnpivot[EndDate1stOfMonth]), ALL(CycleDayUnpivot))

 

And trying updating second measure

 

LatestMonthColumnColor =
VAR maxMonth = [LatestMonth]
RETURN IF(MAX(CycleDays[EndDate1stOfMonth]) = maxMonth, "#EE9771", "#DefaultColor")




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.