Reply
andreazambon
Helper V
Helper V
Partially syndicated - Outbound

Issue with sum and averages between tables

Hi guys. 

Suppose to have those tables:

 

 

ProductionTable   
Production DateProdOrderLinekg
23/06/20241231100
23/06/20241231100
23/06/20241231100
23/06/20241231100
23/06/20244561150
24/06/20244561150
24/06/20244561150
24/06/20244561150
22/06/20247892200
22/06/20247892200
22/06/20247892200

 

OrderTable 
ProdOrderkgDate
12340022/06/2024
45660023/06/2024
78960022/06/2024

 

DateTable 
DateTableMonth
01/06/20246
02/06/20246
03/06/20246
04/06/20246
05/06/20246
06/06/20246
07/06/20246
08/06/20246
09/06/20246
10/06/20246
11/06/20246
12/06/20246
13/06/20246
14/06/20246
15/06/20246
16/06/20246
17/06/20246
18/06/20246
19/06/20246
20/06/20246
21/06/20246
22/06/20246
23/06/20246
24/06/20246
25/06/20246
26/06/20246
27/06/20246

 

The tables are connected following these relationships:

 

 

 

-ProductionTable[Production Date]-->DateTable[Date]

-ProductionTable[ProdOrder]-->OrderTable[ProdOrder]

-OrderTable[date]-->DateTable[Date] (inactive)

 

 

The goal is to build a measure that show me the average of the order's quantity taken by OrderTable, with the possibility to filter in a filter view the Line and the Period. My difficulty is that I don't know how to link the column ProductionTable[Line] with OrderTable[ProdOrder].

The questions could be:

"what is the average dimensions of orders?"

 

The answer is: in 22/06 =500kg, in 23/06 = 600kg.

 

"What is the average dimensions of Orders produced by Line 1?

 

The answer is 500kg.

 

 

As you can see from the tables, the ProductionDate of an order could be different from the Date in the OrderTable. It doesn't matter: the Date in OrderTable is the one i'm interested to check.

 

 

I need to do it in DAX, so please don't suggest something like table merge. 

Some hints? 

Thankyou!

 

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

Syndicated - Outbound

ThxAlot_0-1719259677050.png

 

ThxAlot_1-1719259709406.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



View solution in original post

3 REPLIES 3
andreazambon
Helper V
Helper V

Syndicated - Outbound

Thank you all for replies. 

 

Thanks to your work I've discovered that take the information from the OrderTable is not a good choice.

I'll ask your hel again in a different topic.

 

 

ThxAlot
Super User
Super User

Syndicated - Outbound

ThxAlot_0-1719259677050.png

 

ThxAlot_1-1719259709406.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



rajendraongole1
Super User
Super User

Syndicated - Outbound

Hi @andreazambon - Please find the below steps to get the expected output for 22/6 and 23/6- average dimensions of Orders produced by Line 1

 

 

Model has been defined as per description.

 

rajendraongole1_2-1719252062456.png

 

I have designed the same model as per the above description:

create measures to calculate the average order dimensions

AvgOrderDimensionByLine =
CALCULATE(
    AVERAGE(OrderT[kg]),
    USERELATIONSHIP(OrderT[Date], Date_Tprod[DateTable]),
    VALUES(_Produ[Line])
)

 

 

rajendraongole1_0-1719251946655.png

 

getting the same as expected. please check.

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

 





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

Proud to be a Super User!





avatar user

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)