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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Luis_Caston
Helper III
Helper III

Dinamic color x-axis

Dear all,
I'd like to give red color to the x-axis to the todays weeknumber.
I've created this formula:

Color Numweek =

    var _uparrow = UNICHAR(129137)
    VAR _downarrow = UNICHAR(129139)
    var _variance =
        WEEKNUM(UTCNOW())

    var _numweek = MAX(Calendario[NUMWEEK])    
RETURN

    IF( _numweek = _variance,
         "Red", "Grey")
 
But is not working take a look:todays week is 31 but remains grey.
 
Luis_Caston_0-1722238422130.png

On the contrary at a matrix is working:

 

Luis_Caston_1-1722238480237.png

Do you know why is not working at the x-axis graph?

2 REPLIES 2
Luis_Caston
Helper III
Helper III

Hi!
Thank you for your support!
I've add it here:

 

Luis_Caston_0-1722243492077.png

I've changed the color to blue (when conditions not) to see if something happens but "Red" condition is no working.

Do you guess why?

bhanu_gautam
Super User
Super User

@Luis_Caston  You can try below mentioned way 

First create a measure for Current weeknum

CurrentWeekNumber = WEEKNUM(TODAY())

 

Create  a measure for Color

WeekColor =
VAR _currentWeek = [CurrentWeekNumber]
VAR _numweek = MAX(Calendario[NUMWEEK])
RETURN IF(_numweek = _currentWeek, "Red", "Grey")

 

Select the visualization where you want to apply the conditional formatting.
Go to the Format pane.
Expand the Data colors section.
Click on the fx button next to the color you want to change.
In the Default color dialog, select Field value.
Choose the measure [WeekColor] you created.

 

This approach will not change the color of the x-axis labels directly but will change the color of the data points based on the week number




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
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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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