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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
jaliu1290
Frequent Visitor

Total of all transactions related to one item type

Hello Power BI Community!!

I have a table of Items, Amounts, and associated Transaction IDs and would like a measure to calculate the Expected Outcome.

 

ItemAmountTransactionExpected Outcome (Total of All Transactions)
Square5ABC60
Circle10ABC35
Triangle20ABC80
Square5DEF60
Triangle20DEF80
Triangle20HIJ80

 

Transaction total for ABC = 35, DEF = 25, and HIJ = 20.


Therefore, if want to be able to slice by Square, then I want it to retrieve Transactions ABC and DEF that contained Square items, but then finally sum the entire total amount of those Transactions.

 

Thanks in advance,

 

Jamie

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

ThxAlot_0-1734797571448.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


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


)



View solution in original post

5 REPLIES 5
Kedar_Pande
Super User
Super User

@jaliu1290 

Measure:

Expected Outcome = 
CALCULATE(
SUM('Table'[Amount]),
FILTER(
ALL('Table'[Transaction]),
CONTAINS(
FILTER('Table', 'Table'[Item] = SELECTEDVALUE('Table'[Item])),
'Table'[Transaction],
'Table'[Transaction]
)
)
)

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

v-linhuizh-msft
Community Support
Community Support

Thanks for the replies from ThxAlot and rohit1991.

 

Hi @jaliu1290 ,

 

According to your description I tried different things in Power Query, here's how I did it:

1.Duplicate the table:

vlinhuizhmsft_0-1734931406553.png

 

2. Use these two tables to create a new merged table:

vlinhuizhmsft_1-1734931457961.png

vlinhuizhmsft_2-1734931496427.png

 

3. Expand the columns:

vlinhuizhmsft_3-1734931577646.png

 

4. Perform group by operations:

vlinhuizhmsft_4-1734931668686.png

vlinhuizhmsft_5-1734931858558.png

 

5. Create a many-to-many relationship between the original table and the new table, and create the following visual:

vlinhuizhmsft_6-1734932165271.png

 

Result:

vlinhuizhmsft_7-1734932305142.pngvlinhuizhmsft_8-1734932315767.png

 

Best Regards,
Zhu

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

rohit1991
Super User
Super User

To achieve this in Power BI, you can use a combination of DAX measures and filtering logic. Here's a step-by-step guide:

Steps:

  1. Create a Relationship (if needed): Ensure your data model has a proper relationship between your Items table and Transactions table if they are in separate tables.

  2. Create a DAX Measure for Expected Outcome: Use the following DAX formula to create a measure that calculates the Expected Outcome:
    Expected Outcome = VAR SelectedItems = VALUES(Items[Item])VAR TransactionsWithSelectedItems = CALCULATETABLE(VALUES(Transactions[Transaction]),FILTER(ALL(Items),Items[Item] IN SelectedItems))
    RETURNCALCULATE(SUM(Transactions[Amount]),Transactions[Transaction] IN TransactionsWithSelectedItems)

  3. Visualize the Data:

    • Add a slicer with the Item field.
    • Add a table visual showing the Item, Transaction, and the newly created Expected Outcome measure.

       

  4. Testing:Select different items in the slicer (e.g., "Square"), and the measure should display the summed total of all relevant transactions.

 

ThxAlot
Super User
Super User

ThxAlot_0-1734797571448.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


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


)



This was the simplest and most elegant solution. Thank you!!!

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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