Forum Discussion
adeel726
6 years agoFrequent Visitor
DISTINCT UNION & Summarized Combined.
Hi I have two tables and i am trying to make a summary table using "New Table". The result of the two tables should be something similar to "group by" function bases on both tables. the uniqunes...
- 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,
v-lid-msft
Community Support
6 years agoHi 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,
adeel726
6 years agoFrequent Visitor
Thanks that worked