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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Brutus97
Frequent Visitor

How to compare a record in a table with another table on a number of conditions ?

Hello,

 

I'm strugling with the following in Power Query:

 

I have 2 tables: Salesorderlines and Prognosis.

The Salesorderline table contains the columns: item, quantity and delivery date.

The Prognosis table contains the columns: item, quantity and delivery date.

 

For every row in the Prognosis table, I want to check if it already exists in the (all the records of the) Salesorderline table, based on the following conditions:

 

Salesorderline.item = Prognosis.item

Salesorderline.delivery date > Prognosis date and Salesorderline.deliverydate-5 days> Prognosis date ( so f.e. deliverydate is 15 january, then 10,11,12,13,14 of january are within the selection)

 

If the conditions are fulfilled in a new column in the Prognosis table it should give "Already ordered" else "Not ordered yet"

 

How do I do this Power Query ??

 

Thank you in advance!!!

 

 

 

6 REPLIES 6
v-yingjl
Community Support
Community Support

Hi @Brutus97 ,

There seems to be a lack of correspondence between rows. For example, about Item A12, why 2021-12-12 Prognosis date is corresponding to 2021-1-15 instead of 2021-1-22 delivery date, 2021-1-25 Prognosis date has no correspondence delivery date instead of 2021-1-22 or 2021-1-15 Prognosis date etc. , how to define this correspondence?

Could you please consider sharing more details about this issue for further discussion?

 

Best Regards,
Community Support Team _ Yingjie Li

AlB
Community Champion
Community Champion

@Brutus97 

Just copying the tables in Excel and doing a simple paste here should work.  Otherwise place the tables in an Excel file (don't forget the expected result) and share the excel file.

You have to share the URL to the file hosted elsewhere: Dropbox, Onedrive... or just upload the file to a site like tinyupload.com (no sign-up required).

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Cheers 

 

SU18_powerbi_badge

 

Brutus97
Frequent Visitor

It is like the example below in Excel..

 

Brutus97_0-1610029767056.png

 

Brutus97
Frequent Visitor

Hello A|B,

 

I'm trying to make example tables but I get HTML errors when I want to post the reply.. 

AlB
Community Champion
Community Champion

Hi @Brutus97 

Would you show the two tables (if necessary with dummy data but preserving their structure) and also the expected result? Please share (at least the initial tables) in text-tabular format so that the contents can be copied. Or share the pbix if possible

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

 

Brutus97
Frequent Visitor

Did you see the Excel screenshot? Is it clear for you?

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.