Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Develop matrix with colum on right

I need to develop matrix table with rightside column. something like following. Column1 Column 2 Column3 Matrix1 Matrix2 Matrix 3 Matrix 4 Column 4 Column 5 Column 6 City State Buil...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous 

    Based on your description, you just need to update the calendar table to the following.

    Calendar = ADDCOLUMNS(CALENDAR(MIN('Table'[Date]),MAX('Table'[Date])),"Year-Month",FORMAT([Date],"YYYY-MM"))

    2.Change the type table to the following.

    Type = var a=SUMMARIZE('Table',[Date])
    var b={"Min","Max","Avg"}
    return UNION(a,b)

    3.Change the measure to the following.

    Measure2 =
    VAR a =
        MAXX (
            FILTER ( ALLSELECTED ( 'Table' ), [Cat] IN VALUES ( 'Table'[Cat] ) ),
            [Sample]
        )
    VAR b =
        MINX (
            FILTER ( ALLSELECTED ( 'Table' ), [Cat] IN VALUES ( 'Table'[Cat] ) ),
            [Sample]
        )
    VAR c =
        AVERAGEX (
            FILTER ( ALLSELECTED ( 'Table' ), [Cat] IN VALUES ( 'Table'[Cat] ) ),
            [Sample]
        )
    RETURN
        SWITCH (
            SELECTEDVALUE ( 'Type'[Type] ),
            "Avg", c,
            "Max", a,
            "Min", b,
            CALCULATE (
                [Sample],
                FILTER ( 'Calendar', FORMAT ( [Date], "" ) IN VALUES ( 'Type'[Type] ) )
            )
        )
    

    Output

     

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.