Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
1 year ago
Solved

Add Measure as a Column Subtotal in a Matrix

Hello I'm doing a shift quadrant, and I'd like to know if it's possible to add a measure as a column subtotal. In the following image I have the quadrant and in the blank matrix, the measurements I...
  • danextian's avatar
    danextian
    1 year ago

    Hi Syndicate_Admin 

     

    First, add a day column to your fact table. Then create this disconnected calculated table.

    CombinedDimensions = 
    VAR _day =
        DISTINCT (
            SELECTCOLUMNS (
                Cuadrante,
                "Day", FORMAT ( Cuadrante[Dia], "#,#" ),
                "Sort", Cuadrante[Dia]
            )
        )
    VAR tvb =
        DATATABLE (
            "Day", STRING,
            "Sort", INTEGER,
            {
                { "T", 51 },
                { "V", 52 },
                { "B", 53 }
            }
        )
    RETURN
        UNION ( _day, tvb )
    

    Dont forget to apply custom sort.

    Create this measure to bind your fact table and this disconnected table in a viz.

    CombinedValue = 
    IF (
        SELECTEDVALUE ( CombinedDimensions[Sort] ) <= 31,
        CALCULATE (
            MIN ( Cuadrante[EVENTO] ),
            KEEPFILTERS ( TREATAS ( VALUES ( CombinedDimensions[Sort] ), Cuadrante[Dia] ) )
        ),
        SWITCH (
            SELECTEDVALUE ( CombinedDimensions[Day] ),
            "T", FORMAT ( [Total_mañanas], "#,0" ),
            "V", FORMAT ( [Total_Vacaciones], "#,0" ),
            "B", FORMAT ( [Total_baja], "#,0" )
        )
    )
    

    And the result is

    Reapply conditional formatting.

     

    Please see attached pbix