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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Power Query - Get data from another table if condition is met

Hi all,

 

I need your help to get data from table 2 if some conditions are met there, and this in power query. I have a ref that I can found in both table, and I need to retrieve the "to return value" if Date from table 1 is within Start and End date of table 2. There are overlap in date for the same ref in Table 2, in such case I just need the first value that match the critera. This is what I have:

 

Table 1

RefDate
105.01.2022
203.03.2023
101.03.2023
118.02.2022
313.08.2022
......

 

Table 2

RefStart DateEnd DateValue to return
101.01.200031.12.2002abc
101.01.202230.06.2022def
101.01.202230.11.2022azt
201.01.202331.03.2023uir

 

The result I am looking for

RefDateReturned value
105.01.2022def
203.03.2023uir
101.04.2023null
118.02.2022def
313.08.2022azt
.........

 

Thanks in advance for your help!

4 REPLIES 4
HealthyBob
Regular Visitor

Is IT because you See an Error or is it not selectable? Do you have the right linkage? Or is it just a Table as visual? Then you have to get the Data in the Backend Tables. Otherwise try to geht an measure feom your Table with calcualte(values( which you can select in the If Statement 

Anonymous
Not applicable

Tables are well connected, however IF statement cannot compare a value from a cell to a table, I guess.

HealthyBob
Regular Visitor

Hi,

maybe you can try Something Like that 

 

= If( And("Date Table 1" > " start Date table 2", "Date Table 1"< "end Date Table2), Firstnonblank(value to Return, value to Return), "Else condition"))

 

Im new with Firstnonblank, but it worked for me to Type in the returning value twice.

 

Best

Anonymous
Not applicable

That would be great, but you cannot even select any field from table 2 with a simple if statement

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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