Forum Discussion
Combine multiple measures in a table
- 8 months ago
Hi vipett,
Could you please try with below steps.
1. Create a disconnected table for your final columns
UnifiedColumns(Disconnected table) = UNION( SELECTCOLUMNS( DISTINCT('Calendar'[YYYYMM]), "ColumnType", "Period", "ColumnKey", 'Calendar'[YYYYMM] ), DATATABLE( "ColumnType", STRING, "ColumnKey", STRING, { {"Measure", "AvgForecast6M"}, {"Measure", "AvgShipped6MLY"}, {"Measure", "AvgOpenOrders6M"} } ) )2.Create a measure that returns the correct value based on row context, this will be main measure used in the matrix
Unified Value := VAR ColType = SELECTEDVALUE(UnifiedColumns[ColumnType]) VAR Key = SELECTEDVALUE(UnifiedColumns[ColumnKey]) RETURN SWITCH( TRUE(), ColType = "Period", CALCULATE( [Forecast], 'Calendar'[YYYYMM] = Key ), Key = "AvgForecast6M", [Avg Forecast 6M], Key = "AvgShipped6MLY", [Avg Shipped 6M LY], Key = "AvgOpenOrders6M", [Avg Open Orders 6M], BLANK() )3.Build your matrix as below
Rows: Products
Columns: UnifiedColumns[ColumnKey]
Values: Unified Value measureThanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.
Hi vipett,
Could you please try with below steps.
1. Create a disconnected table for your final columns
UnifiedColumns(Disconnected table) =
UNION(
SELECTCOLUMNS(
DISTINCT('Calendar'[YYYYMM]),
"ColumnType", "Period",
"ColumnKey", 'Calendar'[YYYYMM]
),
DATATABLE(
"ColumnType", STRING,
"ColumnKey", STRING,
{
{"Measure", "AvgForecast6M"},
{"Measure", "AvgShipped6MLY"},
{"Measure", "AvgOpenOrders6M"}
}
)
)2.Create a measure that returns the correct value based on row context, this will be main measure used in the matrix
Unified Value :=
VAR ColType = SELECTEDVALUE(UnifiedColumns[ColumnType])
VAR Key = SELECTEDVALUE(UnifiedColumns[ColumnKey])
RETURN
SWITCH(
TRUE(),
ColType = "Period",
CALCULATE(
[Forecast],
'Calendar'[YYYYMM] = Key
),
Key = "AvgForecast6M", [Avg Forecast 6M],
Key = "AvgShipped6MLY", [Avg Shipped 6M LY],
Key = "AvgOpenOrders6M", [Avg Open Orders 6M],
BLANK()
)3.Build your matrix as below
Rows: Products
Columns: UnifiedColumns[ColumnKey]
Values: Unified Value measure
Thanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.
Thanks, I had to switch 'Key' to something else because Key was a reserved word, but otherwise excellent!