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
EZiamslow
Helper II
Helper II

Match 2 columns from 2 different tables - based on the date and pull the value

Hi,

I'm having trouble matching between two different tables. I'm trying to match between [Date] and [ID] columns from Table1 to Table2 and pull table2[Tool] value. Table2[Date] is equal or 1 day higher than Table1[Date].

 

Please see the sample data below. I'm not sure what I can do to make it work. Table1[tool] is the one I'm trying to get.

 

Any inputs will be greatly appreciated.

 

Table1     (from table2) Table2  
DateIDX1X2X3X4Tool  DateIDTool
7/29/2019123451.21.41.21.1AA 7/30/201912345AA
7/29/2019234562.01.11.21.5BB 7/30/201923456BB
7/29/2019234562.80.81.21.9BB    
7/29/2019534513.60.51.22.3BB 7/30/201953451BB
7/28/2019345674.40.21.22.7AA 7/29/201934567AA
7/27/2019234562.80.81.21.9AA 7/27/201923456AA

 

 

1 ACCEPTED SOLUTION

@EZiamslow 

 

Hi,

 

There are multiple ways of solving this.

 

You may find one of the solutions helpful here

 

Rgds,

Vivek

 

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
Mariusz
Community Champion
Community Champion

Hi @EZiamslow 

Can you provide a sample of what outcome you are expecting?

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Hi @Mariusz 

I'm trying to get value Table2[Tool] in Table1. I have it on my sample.

Hi @EZiamslow

Sorry, I've missed that.

 

You can do it in Query Editor by adding a custom column to the Table1.
Please see the below M code for your column.

let _id = [ID], _date = [Date] in Table.FirstN( Table.Sort( Table.SelectRows( Table2, each [ID] = _id and [Date] >= _date ), { { "Date", Order.Ascending } } ), 1 )[Tool]

Next you will need to expand the list of values.

please see the outcome below.

image.png

 

Let me know if you need any extra help.

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

@vivran22  Thanks your DAX code works.

@Mariusz  I haven't tried yours yet. I will try it and get back to you. I'm still learning. It's good to know that we have multiple ways of doing things. Thank you!

@EZiamslow 

 

Hi,

 

There are multiple ways of solving this.

 

You may find one of the solutions helpful here

 

Rgds,

Vivek

 

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

Mariusz
Community Champion
Community Champion

Hi @vivran22 

I've tried to look at your solution, but could not find anything in the file, just row tables.
Can you republish the file?

ps. thanks for the kudos!

 

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski

 

vivran22
Community Champion
Community Champion

@Mariusz 

 

Hi,

 

I have checked the link and it is working fine. I am not sure what you are seeing when you are accessing the file. I have suggested the solution using DAX (LookupValue). Below is the screenshot:

 

 

Capture.PNG

 

 

Rgds,

Vivek

Mariusz
Community Champion
Community Champion

Hi @vivran22 

Sorry! It was me having a moment, I need another coffee! Smiley Tongue

Thanks 

Mariusz

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.