cancel
Showing results for
Did you mean:
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 Date ID X1 X2 X3 X4 Tool Date ID Tool 7/29/2019 12345 1.2 1.4 1.2 1.1 AA 7/30/2019 12345 AA 7/29/2019 23456 2.0 1.1 1.2 1.5 BB 7/30/2019 23456 BB 7/29/2019 23456 2.8 0.8 1.2 1.9 BB 7/29/2019 53451 3.6 0.5 1.2 2.3 BB 7/30/2019 53451 BB 7/28/2019 34567 4.4 0.2 1.2 2.7 AA 7/29/2019 34567 AA 7/27/2019 23456 2.8 0.8 1.2 1.9 AA 7/27/2019 23456 AA

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Member

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

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.

8 REPLIES 8
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.

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.

Highlighted
Member

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

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.

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.

`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.

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.

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.

Member

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

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:

Rgds,

Vivek

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!

Thanks

Mariusz

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!

Announcements

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

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

Top Solution Authors
Top Kudoed Authors (Last 30 Days)