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
YasarKhan
Frequent Visitor

Create DAX Measure to get data based on condition from two tables?

Hello Experts,

 

I have a situation where I need to calculate quantity based on the condition of two date fields which are placed in two different tables.

 

I am trying to calculate the sum of delivered quantity(Table2-CustPackingSlipTrans) where Table2.delivery date(CustPackingSlipTrans.DeliveryDate) must be less than the Table1.requested ship date(SalesLine.RequestedShipDate).

 

With the above formula, I will be able to calculate the sales OTIF(OnTimeInFull).

 

Relationship: Table1.InventTransId(1):Table2.InventTransId(Many)

 

Table1 - Sales Line
InventTransIdItemIdOrderedQtyRequested Ship Date
LOT-0001ABC1000025-Dec-19

 

Table2 - CustPackingslipTrans
InvenTransIdDelivered QtyDeliveryDate
LOT-0001200012-Nov-19
LOT-0001250001-Dec-19
LOT-0001350031-Dec-19
LOT-0001200002-Jan-19

 

I tried below the DAX query but without success.

 

Delivered Qty = CALCULATE(SUM('stage CUSTPACKINGSLIPTRANS'[QTY]))

 

OTIF = CALCULATE([Delivered Qty], FILTER('stage CUSTPACKINGSLIPTRANS', 'stage CUSTPACKINGSLIPTRANS'[DELIVERYDATE].[Date]<= 'stage SALESLINE’ [REQUESTEDSHIPDATE].[Date]))

 

Can anyone please help me on how to get the above result using DAX Custom Measure.

 

Many Thanks,

Yasar

1 ACCEPTED SOLUTION
Parisha
Employee
Employee

Try modifying your measure as below and check ... OTIF = CALCULATE(sum(CustPackingslipTrans[Delivered Qty]), FILTER('CUSTPACKINGSLIPTRANS', 'CUSTPACKINGSLIPTRANS'[DELIVERYDATE].[Date]<= RELATED('Sales Line'[Requested Ship Date].[Date])))

View solution in original post

2 REPLIES 2
Parisha
Employee
Employee

Try modifying your measure as below and check ... OTIF = CALCULATE(sum(CustPackingslipTrans[Delivered Qty]), FILTER('CUSTPACKINGSLIPTRANS', 'CUSTPACKINGSLIPTRANS'[DELIVERYDATE].[Date]<= RELATED('Sales Line'[Requested Ship Date].[Date])))

@Parisha  Thanks a lot...It is working..great...I did put a lot of time on search and try and finally got the solution..Thanks

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.

Top Solution Authors