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
waldnerr
Helper I
Helper I

Lookup latest value

Hi,

 

i would like create a calculated column called "Program Name" in the "Global Project" for each GlobalProjectKey.

The relevant value is stored in the table "Custom Fields", column "Program Name". 

I would like to select the value with the latest "Date Key" value from the "Project Period" table for each "Globalprojectkey" value.

 

 

"Global Project" table:

GlobalprojectkeyProgram Name
AProgram A
BProgram C

 

1: N (via GlobalProjectKey)

 

"Project Period" table:

GlobalProjectKeyDatekeyProjectPeriodKey
A08/2021Key 1
A07/2021Key 2
B08/2021Key 3
B07/2021Key 4
B06/2021Key 5

 

1:N (via ProjectPeriodKey)

 

"Custom Fields" table:

GlobalProjectKeyProjectperiodKeyProgram NameOther Column AOther Column B
AKey 1Program A  
AKey 1 Other 0 
AKey 2 Other 1 
AKey 2  Other 2
AKey 2Program B  
BKey 3Program C 

 

 

BKey 4Program D 

 

BKey 5Program E 

 

 

I tried to solve this via the LOOKUPVALUE function but wasn't sucessfull, because i was not to able to select the value with the latest datekey per project from the project period table.

I would apprechiate your help to find a solution.

 

Thank you,

Best regards,

Reinhard

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi waldnerr,

 

You can try this new column, it is a little long.

Program Name =
var LastestDate = 
CALCULATE(
    MAX('Project Period'[Datekey]),
    FILTER('Project Period',[GlobalProjectKey]=EARLIER('Global Project'[Globalprojectkey]))
)
var LastestKey = 
CALCULATE(
    MAX('Project Period'[ProjectPeriodKey]),
    FILTER('Project Period',[Globalprojectkey]=EARLIER('Global Project'[Globalprojectkey]) && [Datekey]=LastestDate)
)
RETURN
CALCULATE(
    MAX('Custom Fields'[Program Name]),
    FILTER('Custom Fields',[Globalprojectkey]=EARLIER('Global Project'[Globalprojectkey]) && [ProjectperiodKey]=LastestKey)
)

 

Here's the file I made with your data, you can try it.

 

 

Best Regards

Community Support Team _ chenwu zhu

 

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
v-chenwuz-msft
Community Support
Community Support

Hi waldnerr,

 

You can try this new column, it is a little long.

Program Name =
var LastestDate = 
CALCULATE(
    MAX('Project Period'[Datekey]),
    FILTER('Project Period',[GlobalProjectKey]=EARLIER('Global Project'[Globalprojectkey]))
)
var LastestKey = 
CALCULATE(
    MAX('Project Period'[ProjectPeriodKey]),
    FILTER('Project Period',[Globalprojectkey]=EARLIER('Global Project'[Globalprojectkey]) && [Datekey]=LastestDate)
)
RETURN
CALCULATE(
    MAX('Custom Fields'[Program Name]),
    FILTER('Custom Fields',[Globalprojectkey]=EARLIER('Global Project'[Globalprojectkey]) && [ProjectperiodKey]=LastestKey)
)

 

Here's the file I made with your data, you can try it.

 

 

Best Regards

Community Support Team _ chenwu zhu

 

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

@v-chenwuz-msft 

Thank you, your proposed solution works perfectly.

@Greg_Deckler 

Thank you too for your valuable input.

Greg_Deckler
Community Champion
Community Champion

@waldnerr Seems like you want Lookup Min/Max - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.