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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ColetonC
Regular Visitor

Creating a custom column to identify if item is most current based on date and criteria

I have a table that lists a number of assessments with client, location, and date. Each client and location has multiple assessements performed. I would like to create a custom column that returns a "yes" if the particular assessment for that client and location is the most recent.

 

Below is an example of the data and what I am trying to accomplish. 

Current data:

Assessment NameClientLocation

Date

AssessmentA1

07/02/2021

AssessmentA1

10/01/2022

AssessmentA2

12/02/2022

AssessmentA2

05/02/2023

AssessmentB1

04/14/2023

AssessmentB1

05/15/2024

AssessmentB2

08/20/2023

AssessmentB2

09/25/204

 

Desired outcome

Assessment NameClientLocation

Date

Most Recent

AssessmentA1

07/02/2021

 

AssessmentA1

10/01/2022

Yes

AssessmentA2

12/02/2022

 

AssessmentA2

05/02/2023

Yes

AssessmentB1

04/14/2023

 

AssessmentB1

05/15/2024

Yes

AssessmentB2

08/20/2023

Yes

2 ACCEPTED SOLUTIONS
Sahir_Maharaj
Super User
Super User

Hello @ColetonC,

 

Can you please try the following approach:

Most Recent = 
IF(
    'Table'[Date] = 
        CALCULATE(
            MAX('Table'[Date]),
            ALLEXCEPT('Table', 'Table'[Client], 'Table'[Location])
        ),
    "Yes",
    BLANK()
)

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

View solution in original post

Anonymous
Not applicable

Hi @ColetonC 

 

Thank you very much Sahir_Maharaj for your prompt reply.

 

If you want to customize the columns, try:

 

let
    Source = ...,
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Assessment Name", type text}, {"Client", type text}, {"Location", Int64.Type}, {"Date", type date}}),
    // Add a custom column
    AddCustomColumn = Table.AddColumn(#"Changed Type", "Most Recent", each 
        if [Date] = List.Max(
            Table.SelectRows(#"Changed Type", 
                (x) => x[Client] = [Client] and x[Location] = [Location])[Date]) 
        then "yes" else "")

in
    AddCustomColumn

 

vnuocmsft_0-1731635908512.png

 

Here is the result.

 

vnuocmsft_1-1731636000987.png

 

Regards,

Nono Chen

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

3 REPLIES 3
Sahir_Maharaj
Super User
Super User

Hello @ColetonC,

 

Can you please try the following approach:

Most Recent = 
IF(
    'Table'[Date] = 
        CALCULATE(
            MAX('Table'[Date]),
            ALLEXCEPT('Table', 'Table'[Client], 'Table'[Location])
        ),
    "Yes",
    BLANK()
)

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

Thank you for the response! Can this logic be applied to a custom column on the PowerQuery side when the data is being loaded in?

 

Anonymous
Not applicable

Hi @ColetonC 

 

Thank you very much Sahir_Maharaj for your prompt reply.

 

If you want to customize the columns, try:

 

let
    Source = ...,
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Assessment Name", type text}, {"Client", type text}, {"Location", Int64.Type}, {"Date", type date}}),
    // Add a custom column
    AddCustomColumn = Table.AddColumn(#"Changed Type", "Most Recent", each 
        if [Date] = List.Max(
            Table.SelectRows(#"Changed Type", 
                (x) => x[Client] = [Client] and x[Location] = [Location])[Date]) 
        then "yes" else "")

in
    AddCustomColumn

 

vnuocmsft_0-1731635908512.png

 

Here is the result.

 

vnuocmsft_1-1731636000987.png

 

Regards,

Nono Chen

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

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.