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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Super User
Super User

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

 


@ 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!:
The Definitive Guide to Power Query (M)

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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