Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Min, max and Avg Row

Hi,  I have below data table in PBI -    A B C US            4,080            2,548               860 SA            5,897            2,191               421 IN            1,63...
  • amitchandak's avatar
    5 years ago

    Anonymous ,

    min A = Calculate(min(Table[A]),allselected(Table))

    Max A = Calculate(Amx(Table[A]),allselected(Table))

     

    And So on.

     

    Another way is unpivoting the data A,B,C are the values of New Column Col1 (With A,b ,C), Value with Value

    https://radacad.com/pivot-and-unpivot-with-power-bi
    min  = Calculate(min(Table[Value]),allexcept(Table,Table[Col1]))

    max  = Calculate(max(Table[Value]),allexcept(Table,Table[Col1]))

    Avg= Calculate(Average(Table[Value]),allexcept(Table,Table[Col1]))

     

    display with Show on row in matrix

    https://www.burningsuit.co.uk/blog/2019/04/7-secrets-of-the-matrix-visual/

     

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous,

    I also think unpivoted columns should be a simple way to achieve your requirement.
    If you not want to change your structure, you can try to use following calculate table formula. (I hard code these values into formulas and manually append these aggregated rows)

    Table= 
    VAR temp =
        SELECTCOLUMNS (
            { "Min", "Max", "Avg" },
            "Region", [Value],
            "A",
                SWITCH (
                    [Value],
                    "Min", MINX ( ALL ( 'Table'[A] ), [A] ),
                    "Max", MAXX ( ALL ( 'Table'[A] ), [A] ),
                    "Avg", AVERAGEX ( ALL ( 'Table'[A] ), [A] )
                ),
            "B",
                SWITCH (
                    [Value],
                    "Min", MINX ( ALL ( 'Table'[B] ), [B] ),
                    "Max", MAXX ( ALL ( 'Table'[B] ), [B] ),
                    "Avg", AVERAGEX ( ALL ( 'Table'[B] ), [B] )
                ),
            "C",
                SWITCH (
                    [Value],
                    "Min", MINX ( ALL ( 'Table'[C] ), [C] ),
                    "Max", MAXX ( ALL ( 'Table'[C] ), [C] ),
                    "Avg", AVERAGEX ( ALL ( 'Table'[C] ), [C] )
                )
        )
    RETURN
        UNION ( 'Table', temp )
    

    Regards,

    Xiaoxin Sheng