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
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")

Hi @amitchandak 

 

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

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.