Forum Discussion
DISTINCT UNION & Summarized Combined.
- 6 years ago
Hi adeel726 ,
we can create a calculated table to meet your requirement:
NewTable = ADDCOLUMNS ( DISTINCT ( UNION ( SELECTCOLUMNS ( 'Table1', "Material", [Material], "Period", [Period] ), SELECTCOLUMNS ( 'Table2', "Material", [Material], "Period", [Period] ) ) ), "Prod Order", VAR M = [Material] VAR P = [Period] RETURN CALCULATE ( SUM ( 'Table1'[Production Order] ), FILTER ( 'Table1', 'Table1'[Material] = M && 'Table1'[Period] = P ) ), "Planned Order", VAR M = [Material] VAR P = [Period] RETURN CALCULATE ( SUM ( 'Table1'[Planned Order] ), FILTER ( 'Table1', 'Table1'[Material] = M && 'Table1'[Period] = P ) ), "Delivery Quantity", VAR M = [Material] VAR P = [Period] RETURN CALCULATE ( SUM ( 'Table2'[Delivered Quantity] ), FILTER ( 'Table2', 'Table2'[Material] = M && 'Table2'[Period] = P ) ) )
Best regards,
Create below calculated table.
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar
If I resolve your problem Mark it as a solution and give kudos.
Hi Pravin
Close, the only remaining issue is that from the second table it is creating a new line as opposed to adding the delivery quantity to the same line. As you can see row 5 has a delivery quantity of 30 but that should be in row 1 as the material and preiod are the same. Row 6 is fine as the material is different and there are no records prior that match the material/period combination.
FYI the formula i uses is below.
Table =
Var Tab1=SUMMARIZE(Table1,[Material],[Period],"Plan order",SUM(Table1[Planned Orders]),"Prod order",SUM(Table1[Prod Order]),"Delivered Quantity",0)
Var Tab2=SUMMARIZE('Table2',[Material],[Period],"Plan order",0,"Prod order",0,"Delivered Quantity",SUM('Table2'[Open Quantity])) return
UNION(Tab1,Tab2)
| Material | Period | Prod Order | Planned Orders | Delivery Quantity |
| Part1 | 01/09/2019 | 11 | 88 | 0 |
| Part2 | 01/09/2019 | 11 | 32 | 0 |
| Part1 | 01/10/2019 | 0 | 96 | 0 |
| Part2 | 01/10/2019 | 0 | 0 | 0 |
| Part1 | 01/09/2019 | 0 | 0 | 30 |
| Part3 | 01/10/2019 | 0 | 0 | 20 |
- v-lid-msft6 years agoCommunity Support
Hi adeel726 ,
we can create a calculated table to meet your requirement:
NewTable = ADDCOLUMNS ( DISTINCT ( UNION ( SELECTCOLUMNS ( 'Table1', "Material", [Material], "Period", [Period] ), SELECTCOLUMNS ( 'Table2', "Material", [Material], "Period", [Period] ) ) ), "Prod Order", VAR M = [Material] VAR P = [Period] RETURN CALCULATE ( SUM ( 'Table1'[Production Order] ), FILTER ( 'Table1', 'Table1'[Material] = M && 'Table1'[Period] = P ) ), "Planned Order", VAR M = [Material] VAR P = [Period] RETURN CALCULATE ( SUM ( 'Table1'[Planned Order] ), FILTER ( 'Table1', 'Table1'[Material] = M && 'Table1'[Period] = P ) ), "Delivery Quantity", VAR M = [Material] VAR P = [Period] RETURN CALCULATE ( SUM ( 'Table2'[Delivered Quantity] ), FILTER ( 'Table2', 'Table2'[Material] = M && 'Table2'[Period] = P ) ) )
Best regards,- adeel7266 years agoFrequent Visitor
Thanks that worked