Forum Discussion

vipett's avatar
vipett
Helper III
8 months ago
Solved

Combine multiple measures in a table

I have a dilema, today I have a matrix with Products on Rows YYYYMM in Columns Forecast as Values  Based on what "Version" I select, the date range in YYYYMM changes. Next to this, I have anothe...
  • ajaybabuinturi's avatar
    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 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.