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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Ritaf
Responsive Resident
Responsive Resident

Sum of values of on table according to existence in other in same period

Hi, 
I have a table of purchase transactions of products and dates,
and a table of warehouse entries by dates.
I need to sum of values of purchases just for products with at least one entry on the year with the purchase like on the picture.
Is this the way to do it with DAX?
The link for the sample PBIX:
https://drive.google.com/file/d/1Or0XWXEYVEGYirSQfJUyIGObgw9G3mlm/view?usp=sharing


Capture.JPG

 

. attached

2 ACCEPTED SOLUTIONS
DataInsights
Super User
Super User

@Ritaf,

 

Try this measure. I added a relationship between the calendar and entries tables. To confirm the logic: sum the purchase value for each product that has at least one row in the entries table (for the selected year).

 

Purchases with Entry =
CALCULATE (
    SUM ( purchase[value] ),
    FILTER ( products, NOT ISEMPTY ( RELATEDTABLE ( entries ) ) )
)

 

DataInsights_0-1652191260849.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

@Ritaf,

 

Glad to hear the solution works.

 

If the connection between the purchase and entries tables is PurchaseItemID, the DAX would need to be modified. In a star schema, there aren't relationships between fact tables (the relationships are between dimension and fact tables), which prevents you from using RELATEDTABLE as it exists in the measure.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
v-henryk-mstf
Community Support
Community Support

Hi @Ritaf ,

 

Whether the advice given by @DataInsights  has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.


Looking forward to your feedback.


Best Regards,
Henry

DataInsights
Super User
Super User

@Ritaf,

 

Try this measure. I added a relationship between the calendar and entries tables. To confirm the logic: sum the purchase value for each product that has at least one row in the entries table (for the selected year).

 

Purchases with Entry =
CALCULATE (
    SUM ( purchase[value] ),
    FILTER ( products, NOT ISEMPTY ( RELATEDTABLE ( entries ) ) )
)

 

DataInsights_0-1652191260849.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you!
This solution is perfect in this context.
One more question:
If the model is built so that there is a connection between purchase transactions and entries by purchaseitemid ( not by-product like in my sample file) is this the way to handle it with DAX or do I need to build this logic in the model itself?

@Ritaf,

 

Glad to hear the solution works.

 

If the connection between the purchase and entries tables is PurchaseItemID, the DAX would need to be modified. In a star schema, there aren't relationships between fact tables (the relationships are between dimension and fact tables), which prevents you from using RELATEDTABLE as it exists in the measure.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.