cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EZiamslow Regular Visitor
Regular Visitor

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

Accepted Solutions
vivran22 Member
Member

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

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

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

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

 

EZiamslow Regular Visitor
Regular Visitor

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

Hi @Mariusz 

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

vivran22 Member
Member

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

@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

Highlighted
Super User
Super User

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

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

 

Super User
Super User

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

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 Member
Member

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

@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

Super User
Super User

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

Hi @vivran22 

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

Thanks 

Mariusz

EZiamslow Regular Visitor
Regular Visitor

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

@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!

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)