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

DAX Sum Column based on condition in 2 other tables

I'm trying to calculate the Sales Order Qty of items that fall under defined campaigns. However, the information is scattered across a few related tables as shown in the image below. What DAX formula should I use to calculate the total Sales Order Qty within campaign periods using the data from different tables?

PowerBI.jpg

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @wktan ,

 

It's better to share some sample data because you data model looks quite complicate.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
community_pinki
Helper II
Helper II

Hey @wktan  ,

Please try using this measure :-

 

Sales Order Quantity = CALCULATE
(
SUM(SalesOrderLines[OrderSalesQuantity]),
DATESBETWEEN(SalesOrderHeadersV2[OrderCreationDateTime],
MIN(Campaigns[StartDate]),
MAX(Campaigns[EndDate])
))

Thanks @community_pinki for the suggestion.
I have tried using this measure and added it to a matrix visual (with all the campaigns listed on rows) but it shows the following error.

 

wktan_0-1627522230653.png

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.