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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
deaconb
Helper I
Helper I

Conditional format latest value per user

I'm working on a report which pulls together several sources of training data. One of the widgets we need is for new employees working through the training program and capturing their training events by week. The ask from stakeholders is to color code a given user's lastest training week which I felt I could accomplish from conditional formatting. 

 

I have the following formulas: 

1. Week of Training

Week of Training =

var saturdaybefore
    CALCULATE
    (MIN('Employee'[Proficiency Training Start Date]) - WEEKDAY(MIN('Employee'[Proficiency Training Start Date]), 2))-1

RETURN
IF(YEAR(saturdaybefore) < YEAR(MIN('Employee'[Proficiency Training Start Date])), BLANK(), ROUNDUP(DIVIDE(DATEDIFF(saturdaybefore, 'Data'[Date of Training], Day),7), 0))

 

2. I then created a measure to assess the max week of each user: 

Measure =

var maxweek =
CALCULATE(
    MAXX('Data',[Week of Training] ),
    ALLEXCEPT(Data', 'Data'[USERNAME])
)

RETURN
IF(ISBLANK(maxweek), 0,
IF(Max('Data'[Week of Training]) =maxweek, 2, 1)
)
 
 
I want to color a given user's maximum week orange. I thought I could accompish doing this with my measure above and setting 2 to be orange (the field format is number), but it's only formatting the absolute latest training date (e.g., green box value) and not everyone's latest training week date (e.g. red box values). I realize I am currently using gradient conditional formatting but it shouldn't affect that the latest training week for a user isn't shading properly.
deaconb_0-1737650513816.png

 

 
Here's some truncated sample data to show you my measure is working properly: 
USERNAMEDate of Training SYSIDProficiency Start DateWeek of TrainingMeasure
user111/6/2024 00:008609789  0
user21/21/2025 00:00904309410/7/2024 00:00162
user212/15/2024 00:00887309110/7/2024 00:00111
user212/11/2024 00:00885076910/7/2024 00:00101
user212/11/2024 00:00885074110/7/2024 00:00101
user212/2/2024 00:00878613310/7/2024 00:0091
user212/1/2024 00:00877776710/7/2024 00:0091
user212/1/2024 00:00877776310/7/2024 00:0091
user211/30/2024 00:00877514110/7/2024 00:0081
user211/30/2024 00:00877513310/7/2024 00:0081
user211/27/2024 00:00876081910/7/2024 00:0081
user211/17/2024 00:00868430410/7/2024 00:0071
user211/13/2024 00:00865942210/7/2024 00:0061
user211/4/2024 00:00859257710/7/2024 00:0051
user211/3/2024 00:00858476910/7/2024 00:0051
user210/30/2024 00:00856513410/7/2024 00:0041
user210/30/2024 00:00856513110/7/2024 00:0041
user210/30/2024 00:00856512710/7/2024 00:0041
user210/24/2024 00:00852685110/7/2024 00:0031
user210/22/2024 00:00850504110/7/2024 00:0031
user210/22/2024 00:00850502610/7/2024 00:0031
user210/16/2024 00:00846718810/7/2024 00:0021
user210/16/2024 00:00846718810/7/2024 00:0021
user210/16/2024 00:00846718810/7/2024 00:0021
user210/11/2024 00:00843969010/7/2024 00:0011
user210/11/2024 00:00843969010/7/2024 00:0011
user312/14/2024 00:00887022110/7/2024 00:00102
user312/8/2024 00:00882778510/7/2024 00:00102
user312/5/2024 00:00880787710/7/2024 00:0091
user312/4/2024 00:00880766410/7/2024 00:0091
user312/4/2024 00:00880699010/7/2024 00:0091
user311/26/2024 00:00874473910/7/2024 00:0081
user311/25/2024 00:00873716010/7/2024 00:0081
user311/24/2024 00:00873202010/7/2024 00:0081
user311/23/2024 00:00873182210/7/2024 00:0071
user311/20/2024 00:00871043610/7/2024 00:0071
user311/10/2024 00:00863334210/7/2024 00:0061
user311/10/2024 00:00863332610/7/2024 00:0061
user311/9/2024 00:00863034910/7/2024 00:0051
user311/6/2024 00:00860330810/7/2024 00:0051
user311/1/2024 00:00857829410/7/2024 00:0041
user310/23/2024 00:00851779210/7/2024 00:0031
user310/22/2024 00:00850990910/7/2024 00:0031
user310/19/2024 00:00848836910/7/2024 00:0021
user310/19/2024 00:00848835810/7/2024 00:0021
user310/9/2024 00:00842594210/7/2024 00:0011
3 REPLIES 3
Sahir_Maharaj
Super User
Super User

Hello @deaconb,

 

Can you please try this approach:

Latest Training Week = 
VAR MaxWeekPerUser = 
    CALCULATE(
        MAX('Data'[Week of Training]),
        ALLEXCEPT('Data', 'Data'[USERNAME])
    )
VAR IsLatestWeek = 
    IF(
        MAX('Data'[Week of Training]) = MaxWeekPerUser,
        2, -- Indicates the latest week
        1  -- Indicates all other weeks
    )
RETURN
IsLatestWeek

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Unfortunately this results in the same outcome for formatting as above where the expected result is the red boxes and green box being orange, but only the green box is orange. 

Your measure and my original measure are basically the same. My measure is already working for assessing the latest week or not. I don't understand why it isn't being accepted as part of the conditional formatting. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.