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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MichaelStrauss
Frequent Visitor

conditional format x-axis and data labels color by the selected date

Hi all,

 

I am trying to conditional format the color of my x-axis labels and data labels. My target is only show an axis label and data label for the min and max selected date (there is a date slicer)

 

I thought about creating a measure that will color the min and max date to black and all other selected dates to white 

 

My date table has a column for the date (date format) which is filtered by the user, and a column for the month-year combination (text format)

I use the month-year column in my x-axis label and some measure for the y-axis

 

MichaelStrauss_1-1674816442167.png

 

the measure I wrote is:

 

Var _maxdate = CALCULATE(MAX(dimDate[Date].[Date]),ALLSELECTED(dimDate[Date]))
Var _mindate = CALCULATE(MIN(dimDate[Date].[Date]),ALLSELECTED(dimDate[Date]))

var _Condition = (month(max(dimDate[Date])) = MONTH(_maxdate) && year(max(dimDate[Date])) = year(_maxdate)) ||
                 (month(min(dimDate[Date])) = MONTH(_mindate) && year(min(dimDate[Date])) = year(_mindate))

return if(_Condition,"#000000","#FFFFFF")
 
If I put this measure as my ruke in conditional formatting, all labels are black ("#000000") ...
Funny is that if I put this measure in a matrix with my year-month column, the wanted result is returned:
 
MichaelStrauss_2-1674816921695.png

 

I don't use my date column in the graph because the measure doesn't work with date hierarchy and because I want to show a short month-year format in a uinque way

 

Help will be appreciated

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@MichaelStrauss , Try a measure like

 

Measure =
var _max = maxx(allselected(Date),Date[Date])
var _min = minx(allselected(Date),Date[Date])
return
if(Max(Date[Date]) = _max || Min(Date[Date]) =_min, "#000000","#FFFFFF")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

Thank you for your answer. Unfortunately the measure does not work, all labels returned black (#000000)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.