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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.