many to many?

ruthhacche

Board Regular
Joined
Sep 22, 2017
Messages
84
I have the set up below. Transaction 01234 has an invoice for £2.00 and a Credit for £0.50 (net £1.50) This was settled by £1.00 paid on one date and £0.50 paid on another date. The customer table links to both via a customer ID in all 3 tables not shown.

For all transactions in my Order table I want to know how much has been allocated in the Allocations table. I have tried
Paid = CALCULATE ( sumx(ALLOCATIONS, ALLOCATIONS[Value]), CROSSFILTER ( ALLOCATIONS [ref]] ,ORDERS [Ref], Both) )
It is finding the correct value for this transaction line but it is losing the filter and crossing every order to every order to return millions of lines.

I am no doubt being thick. Please help.

1594996661000.png
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
using Power Query three Mcodes that I believe are readable in BI. I don't have or use BI

Orders
Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"REF", type text}, {"Value", Currency.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"REF"}, {{"ValueTotal", each List.Sum([Value]), type number}})
in
    #"Grouped Rows"

Allocations
Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"REF", type text}, {"Value", Currency.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"REF"}, {{"AllocationsSum", each List.Sum([Value]), type number}})
in
    #"Grouped Rows"

Merged Queries.
Rich (BB code):
let
    Source = Table.NestedJoin(Orders, {"REF"}, Allocations, {"REF"}, "Allocations", JoinKind.LeftOuter),
    #"Expanded Allocations" = Table.ExpandTableColumn(Source, "Allocations", {"AllocationsSum"}, {"Allocations.AllocationsSum"}),
    #"Replaced Value" = Table.ReplaceValue(#"Expanded Allocations",null,0,Replacer.ReplaceValue,{"Allocations.AllocationsSum"})
in
    #"Replaced Value"

Book10
ABC
1REFValueTotalAllocations.AllocationsSum
2012341.51.5
30567830
Sheet5
 
Upvote 0

Forum statistics

Threads
1,223,786
Messages
6,174,548
Members
452,572
Latest member
KP53

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top