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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to find and return same value based on latest date found in another column?

Hi all,

 

I am needing a calculated column that returns the most recent value that appears 'Ordinary/Non-Ordinary' column and replicate that value for all rows for the same Provider ID (regardless of Week Ending).

 

In the example below, as 'Ordinary' was the value that appeared in the 'Ordinary/Non-Ordinary' column on the 22nd of October (deemed to be the latest date that Provider ID 10025304 appeared in the dataset), therefore I want to see 'Ordinary' returned in ALL rows in the 'Ordinary/Non-Ordinary (latest)' column. However it is returning an error:

aarcheco_0-1699491165974.png

 

Ordinary/Non-Ordinary? (latest) = lookupvalue('Provider ID'[Ordinary/Non-Ordinary?],
'Provider ID'[Week Ending],'Provider ID'[Latest Week Provider ID exists],
'Provider ID'[Provider ID],'Provider ID'[Provider ID])

 

 

 

For some reason I was able to achieve what I was hoping for in the 'Provider (latest) column. See how it returns 'PM EN1' for ALL rows for Provider ID 10025304 (regardless of week ending date). This Provider ID used to have 'PM RN1' prior to the 1st of October, and the dax function in 'Provider (latest)' ignores that as it was before the latest date of the 22nd of October.

 

aarcheco_1-1699491165995.png

 

Provider (latest) = lookupvalue('Provider ID'[Provider],
'Provider ID'[Provider ID],'Provider ID'[Provider ID],
'Provider ID'[Week Ending],filter(ALL('Provider ID'[Week Ending]),'Provider ID'[Week Ending]='Provider ID'[Latest Week Provider ID exists]))

 

I'm not sure how to resolve the error I'm experiencing in the 'Ordinary/Non-ordinary? (latest)' column though.

 

Any help would be much appreciated!

1 ACCEPTED SOLUTION
ERD
Community Champion
Community Champion

Hi @Anonymous , try this pattern:

Column =
VAR _dt =
    CALCULATE (
        MAX ( 'Provider ID'[Week Ending] ),
        ALLEXCEPT ( 'Provider ID', 'Provider ID'[Provider ID] )
    )
VAR _status =
    CALCULATE (
        MAX ( 'Provider ID'[Ordinary/Non-Ordinary?] ),
        ALLEXCEPT ( 'Provider ID', 'Provider ID'[Provider ID] ),
        'Provider ID'[Week Ending] = _dt
    )
RETURN
    _status

ERD_0-1699513921590.png

 

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

2 REPLIES 2
ERD
Community Champion
Community Champion

Hi @Anonymous , try this pattern:

Column =
VAR _dt =
    CALCULATE (
        MAX ( 'Provider ID'[Week Ending] ),
        ALLEXCEPT ( 'Provider ID', 'Provider ID'[Provider ID] )
    )
VAR _status =
    CALCULATE (
        MAX ( 'Provider ID'[Ordinary/Non-Ordinary?] ),
        ALLEXCEPT ( 'Provider ID', 'Provider ID'[Provider ID] ),
        'Provider ID'[Week Ending] = _dt
    )
RETURN
    _status

ERD_0-1699513921590.png

 

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Anonymous
Not applicable

Brilliant, thanks @ERD. Worked as required!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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