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.

Column1Column 2Column3Matrix1Matrix2Matrix 3Matrix 4Column 4Column 5Column 6
CityStateBuilding01/0101/0201/0301/04minmaxavg
santa monicaCaliforniaXYZ St102271572214
          
  • 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.

     

     

11 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

    You can try the following solution.

    Sample data 

    Sample measure

    Sample = SUM('Table'[Value])

    1.Create a type table

    2.Create a measure

    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], FORMAT ( 'Table'[Date], "" ) IN VALUES ( 'Type'[Type] ) )
        )
    

    Then put the following field to the matrix.

    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.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      it works now however , I am not able to use my slicer - Jan, 24, feb 24 etc... still it shows data for all months. I have created new column mmm-yy formate but that filter is not applying on this report. rest of other slicer filter works.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous 

        Please refer to the following.

        1.Create a calendar table.

        Calendar = ADDCOLUMNS(CALENDAR(DATE(2023,1,1),DATE(2023,12,31)),"Year-Month",FORMAT([Date],"YYYY-MM"))

        2.Change the type table to the following.

        Type = var a=SUMMARIZE('Calendar',[Year-Month])
        var b={"Min","Max","Avg"}
        return UNION(a,b)

        3.Create a relationship between calendar table and data table.

         

        4.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'[Year-Month] ),
                "Avg", c,
                "Max", a,
                "Min", b,
                CALCULATE (
                    [Sample],
                    FILTER ( 'Calendar', 'Calendar'[Year-Month] IN VALUES ( 'Type'[Year-Month] ) )
                )
            )
        

        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.

         

         

  • Hi Anonymous 

     

    You can achieve that by hiding columns.  It's a tedious work-around but it works.

     

     

    Custom Matrix Columns.pbix

     

    • For both Values and Column headers, set Text-Wrap to off.
    • Add the measures in the order you want the totals to appear.
    • Shrink the Min, Max, and Avg columns (in the Month columns) until they are invisible.
    • In the column totals, shrink Total.
    • In the column totals, change the Subtotal Label to a space to hide.
  • Anonymous's avatar
    Anonymous
    Not applicable

    I see as following not on right side

     

     

    • gmsamborn's avatar
      gmsamborn
      Icon for Super User rankSuper User

      I would try to shrink the column you don't want to see.  For example, if it's [Max1] that you want to hide then you'll have to shrink it below each of the dates.

       

      Does that make sense?

       

      (I said at the start that it is tedious.)

       

    • lbendlin's avatar
      lbendlin
      Icon for Super User rankSuper User

      Don't try to make Power BI into something it is not.  Use separate visuals.

       

      gmsamborn was very generous to describe this as tedious. I would have used different wording.