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
Anonymous
Not applicable

Adding highlight to a column in visual based on date

I would like the column in this matrix visual where the reporting end of week is the most recent one passed to be highlighted in yellow.  For example, today is 2/24 so 2/19 would be the most recent previous end of week date.  I looked under conditional formatting but I don't see how to make this work with the options.  Any help would be appreciated.

 

BrandonJ_1-1614182511932.png

 

 

 

1 ACCEPTED SOLUTION

Hi, @Anonymous 

 

You may modify the 'Calendar' table as below.

 

Calendar = 
ADDCOLUMNS(
    CALENDARAUTO(),
    "EndofWeek",
    var d =[Date]
    return
    MAXX(
        FILTER(
            CALENDARAUTO(),
            YEAR([Date])*100+WEEKNUM([Date])=YEAR(d)*100+WEEKNUM(d)
        ),
        [Date]
    )
)

 

 

Result:

 a1.png

 

a2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

c1.png

 

Calendar(a calculated table):

Calendar = 
ADDCOLUMNS(
    CALENDARAUTO(),
    "EndofWeek",
    var d =[Date]
    return
    MAXX(
        FILTER(
            CALENDARAUTO(),
            YEAR([Date])*100+WEEKNUM([Date])=YEAR(d)*100+WEEKNUM(d)
        ),
        [Date]
    )-1
)

 

Relationship:

c2.png

 

You may create a measure and set conditional format based on the measure as below.

Color Control = 
var d = MAX('Calendar'[EndofWeek])
var lastweeknum = 
CALCULATE(
    MAX('Calendar'[EndofWeek]),
    FILTER(
        ALL('Calendar'),
        [EndofWeek]<
        CALCULATE(
            MAX('Calendar'[EndofWeek]),
            FILTER(
                ALL('Calendar'),
                [Date]=TODAY()
            )
        )
    )
)
return 
IF(
    d = lastweeknum,
    "red"
)

 

c3.png

 

Result(Today is 3/1/2021):

c4.png

 

Best Regards
Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

One thing i noticed about that calendar:  one of the days is after the after the end-of-week, every week.

BrandonJ_0-1614615687380.png

 

Hi, @Anonymous 

 

You may modify the 'Calendar' table as below.

 

Calendar = 
ADDCOLUMNS(
    CALENDARAUTO(),
    "EndofWeek",
    var d =[Date]
    return
    MAXX(
        FILTER(
            CALENDARAUTO(),
            YEAR([Date])*100+WEEKNUM([Date])=YEAR(d)*100+WEEKNUM(d)
        ),
        [Date]
    )
)

 

 

Result:

 a1.png

 

a2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

VijayP
Super User
Super User

@Anonymous 

You can Create a measure using in The Field Value option in Conditional Formatting

if(Selectedvalue(Date)=26 Feb 2021 - 7 , "Red", "")
(for this =26 Feb 2021 - 7

you need to build dynamic field based on the behaviour of your data).

 




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Anonymous
Not applicable

I tried this but it won't let me select reportingEndofWeek as a field - maybe because it's a date.

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.