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
Omega
Impactful Individual
Impactful Individual

Merge tables using latest dates

Dears, 

 

I am new to BI and I have a small challenge:

 

I have 3 tables: Sales, QTY and Mapping:

 

Sales:                             QTY:                         Mapping:      

Item| Sales                     Item| QTY                       Item| Item2| Date

A     | 50                         D     | 53                          A   | D      | 27/5/2017

B     | 71                         E      | 67                          A   | Z       | 29/5/2017 

C     | 85                         Z      | 70                          A   | X       | 26/5/2017

                                      X      | 100

Action: I'd like to create a new table that takes items from sales and get the corresponding QTY from the QTY table based on latest mapping in the Mapping table. For example, A sales = 50 but QTY = 70 = Z because Z have the latest mapping of A.

 

How to implement such table?

 

Thanks!

1 ACCEPTED SOLUTION

@Omega

 

Hi,

Maybe you didn’t create relationships among the tables. That could be why the sales is empty. Do the relationships look like this below?

If so, you can use these two measures to get “item2” and “sales”.

Item2Measure =

CALCULATE ( VALUES ( Mapping[item2] ), LASTDATE ( Mapping[date] ) )

QTYMeasure =

CALCULATE ( VALUES ( Qty[qty] ), LASTDATE ( Mapping[date] ) )Merge tables using latest dates02.jpg

 

 

Community Support Team _ Dale
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

8 REPLIES 8
Greg_Deckler
Community Champion
Community Champion

Are you trying to do this in DAX or M or do you care?

 



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...
Omega
Impactful Individual
Impactful Individual

Can you please share both if possible and the difference between both in terms of performance and easiness to implement? Thanks!

Hi, @Omega

 

If you want to use DAX, this formula will help.

QTYMeasure =

CALCULATE ( VALUES ( Qty[qty] ), LASTDATE ( Mapping[date] ) )Merge tables using latest dates.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Omega
Impactful Individual
Impactful Individual

Instead of getting the QTY from QTY table, how to get item 2 from mapping table? Meaning, I'll have two columns, one that have A and the other have Z.

 

Thanks!

Omega
Impactful Individual
Impactful Individual

@v-jiascu-msft 

 

Hi Dale,

 

I tried your method but sales are empty. Don't know why 😞 

 

Please advise. 

@Omega

 

Hi,

 

Did this work? What else can I do for you?

 

Best Regards!

Dale

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

@Omega

 

Hi,

Maybe you didn’t create relationships among the tables. That could be why the sales is empty. Do the relationships look like this below?

If so, you can use these two measures to get “item2” and “sales”.

Item2Measure =

CALCULATE ( VALUES ( Mapping[item2] ), LASTDATE ( Mapping[date] ) )

QTYMeasure =

CALCULATE ( VALUES ( Qty[qty] ), LASTDATE ( Mapping[date] ) )Merge tables using latest dates02.jpg

 

 

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Omega
Impactful Individual
Impactful Individual

Thanks for the reply. I'll try to implement and let you know if I'm having challenges. 🙂 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors