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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Yasser92
Frequent Visitor

Complicated case

Hi everyone, 

 

I have two tables, and I'm looking for matching Table1's rows with table2's rows like I'm showing on the table below 

 

Table1: 

Order NLine NDelivery Date
L12115/01/2017
L12717/02/2017
L13102/03/2017
L14220/03/2017
L15419/05/2017
L15501/02/2017
L14301/02/2017
L20108/08/2017

 

Table2 :

 

Order NLine NExpected DelivDate
L12121/08/2017
L12722/08/2017
L13123/08/2017
L14324/08/2017
L11225/08/2017
L154 
L15524/08/2017
L14524/08/2017
L12 
L21201/08/2017
L301 
L12124/08/2017

 

 

Result :

 

Order NLine NDelivery DateExpected DelivDate
L12115/01/201724/08/2017
L12717/02/201722/08/2017
L13102/03/201723/08/2017
L14220/03/2017 
L15419/05/2017 
L15501/02/201724/08/2017
L14301/02/201724/08/2017
L20108/08/2017 



I used this code as a solution: 
TableResult = SUMMARIZE(
GENERATE(
Table1; Var OrderNum = 'Table1'[Order N]
Var LineNum = 'Table2'[Line N]
return FILTER('Table2'; 'Table2'[Order N]=OrderNum && 'Table2'[Line N]=LineNum )
);
Table2[Order N]; Table2[Line N];
"Delivery Date"; MAX(Table2[Expected DelivDate])
)

 

But that doesn't really work.

 

Someone can help me please.

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

does it have to be single formula?
why can't you add a calculated column with Expected Delivery Date to Table1?

Also - are you creating this table to calculate time difference only? if so this should be possible to achieve with a measure, without creating a new table

EDIT - this calculated formula witll work when added to Table1

Expected Delivery Date= 
VAR CurrentOrder = Table1[Order N]
VAR CurrentLine = Table1[Line N]
RETURN
CALCULATE(MAX(Table2[Expected DelivDate]),Table2[Order N]=CurrentOrder,Table2[Line N]=CurrentLine)


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

2 REPLIES 2
Stachu
Community Champion
Community Champion

does it have to be single formula?
why can't you add a calculated column with Expected Delivery Date to Table1?

Also - are you creating this table to calculate time difference only? if so this should be possible to achieve with a measure, without creating a new table

EDIT - this calculated formula witll work when added to Table1

Expected Delivery Date= 
VAR CurrentOrder = Table1[Order N]
VAR CurrentLine = Table1[Line N]
RETURN
CALCULATE(MAX(Table2[Expected DelivDate]),Table2[Order N]=CurrentOrder,Table2[Line N]=CurrentLine)


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Thank you a lot for the response; 

 

It's more useful for my case; 

 

And you are right, I want to make some measures, but not directly on the Expected Delivery date and the Delivery date. I should create two other columns : 

Column1 = If(Delivery Date - Expected DelivDate >7;0;1)

Calumn2= If(Delivery Date - Estimate DelivDate>7;0;1)

 

Estimate DelivDate is estimated by our Service and the expected DelivDate is estimated by our supplier.

 

After that, I'll add a third column which is the max (Column1;Column2) and calculate the percentage of the sum(Calumn3)Divided by count(Orders).

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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