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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Olwin
Frequent Visitor

Sum from another table

Hi there,

 

I have a table relation like below:

1. Location (Loc Code)

2. Item (Item Code)

3. Shipment Planning (Planning No, Loc Code, Item Code, Quantity)

  • Relationship with Location = Many-to-One (Location.Loc Code = ShipmentPlanning.Loc Code)
  • Relationship with Item = Many-to-One (Item.Item Code = ShipmentPlanning.Item Code)

4. Order Lines (Order No, Item Code, Loc Code)

  • Relationship with Location = Many-to-One (Location.Loc Code = OrderLines.Loc Code)
  • Relationship with Item = Many-to-One (Item.Item Code = OrderLines.Item Code)

 

My goal is to show total "Quantity" from "Shipment Planning" for each "Order Line" with the same Item and Location.

Kindly please help 😊

Thanks.

 

Sample Data

Location (A & B)

Item (X1 & X2)

Shipment Planning

Shipment Planning NoItemLocationQuantity
SP#01X1A10
SP#02X2A20
SP#03X1B30
SP#04X1A17

 

Order Lines

Order NoItemLocationTotal Shipment Planning
SO#01X1A27
SO#02X2A20
SO#03X1A27
SO#04X1B30
1 ACCEPTED SOLUTION
speedramps
Community Champion
Community Champion

Download this exampl PBIX solution from Onedrive

Click here 

speedramps_0-1738672809414.png

 

speedramps_1-1738672858441.png

 

 

Please click thumbs up for the suggestion,

and click [accept solution] if it works.

 

Your question is a bit vague, always provide an example desired output to clarify what is required.

 

 

View solution in original post

6 REPLIES 6
speedramps
Community Champion
Community Champion

Download this exampl PBIX solution from Onedrive

Click here 

speedramps_0-1738672809414.png

 

speedramps_1-1738672858441.png

 

 

Please click thumbs up for the suggestion,

and click [accept solution] if it works.

 

Your question is a bit vague, always provide an example desired output to clarify what is required.

 

 

Hi @speedramps  I have see your given example file, and found that the key to get correct result is the selection of "Item No."

 

Previously, I show "Item No." in my visual from my "Order Lines" table, but after I change the source table for "Item No." from Item table, the total is correct automatically.

 

Thanks for your help 😊

speedramps
Community Champion
Community Champion

@Olwin thank you.

Yes you understand correctly.

 

That is why I provide a diagram of the relationships and highlighted in red which fields you needed to select from which tables to use those relationships correctly.

 

 

For me the joy cones from not just giving a solution but teaching the method.

 

Well done on learning it!

Bibiano_Geraldo
Super User
Super User

Hi @Olwin ,

To achieve your goal, you need to create a measure to look like this:

TotalShipmentPlanning = 
CALCULATE(
    SUM('Shipment Planning'[Quantity]),
    FILTER(
        'Shipment Planning',
        'Shipment Planning'[Item] = SELECTEDVALUE('Order Lines'[Item]) &&
        'Shipment Planning'[Location] = SELECTEDVALUE('Order Lines'[Location])
    )
)

 

Expected Output:

Bibiano_Geraldo_0-1738672929747.png

Please see attached file

parry2k
Super User
Super User

@Olwin BTW, here is the output of the solution.

 

parry2k_0-1738672576021.png

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Olwin see the attached solution, in nutshell, you need the following two measures:

 

Planning Qty = SUM ( ShipmentPlanning[Quantity] )

Total Shipment Planning = 
SUMX ( 
    SUMMARIZE (     
        OrderLines,
        'Item'[Items],
        Location[Location],
        "@Planning Qty", [Planning Qty]
    ), 
    [@Planning Qty] 
)

 

 

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors