Forum Discussion

mg-66's avatar
mg-66
Regular Visitor
4 years ago
Solved

Calculate Average from highest X values

Hello everyone,

I am new to Power BI and could need your help.

 

I have a Dataset that consistes of many tables and looks now like this:

DateTemp......
.....105,2.....
.....103,3.....
.....

98,7

.....
.....99,1.....
.....101,5.....
.....99,8.....

 

The other columns should be irrelevant for now. The Time at which these measures where taken doesn't play a role for me.

I wand to add a measure to calculate the average of my 2 highest Temp. values.

Maybe we can order this Column in a descending order and choose the top values to build then the average from them.

 

Thanks for your help and explanation.

Best Regards

 

 

  • mg-66 , Create a column Rank

     

    R1= Rankx(Table, [Temp],,desc, dense)

     

    Then create a measure

     

    Averagex(filter(Table, Table[R1]<=2), Table[Temp])

3 Replies

  • mg-66 , Create a column Rank

     

    R1= Rankx(Table, [Temp],,desc, dense)

     

    Then create a measure

     

    Averagex(filter(Table, Table[R1]<=2), Table[Temp])

    • mg-66's avatar
      mg-66
      Regular Visitor

      amitchandak thank you for your Answer again. But this approach is not working. I also can not tell why or whats mistake I'm doing maybe.

    • mg-66's avatar
      mg-66
      Regular Visitor

      amitchandak thanks alot, it works now ğŸ˜€.

      I would like to add something.

      I want to do the same, but sort the Temp. according to their day and to their Starting Time (ST). Like in this table for example:

      DaySTTempRank
      18am105,21
      18am103,32
      18am

      98,7

      3
      110am99,13
      110am101,51
      110am99,82
      28am105,41
      28am100,32
      28am96,73
      210am97,72
      210am98,81

      Then I will calculate the average in the same way by clicking the Day & Starting Time (ST) Slicer/Filter in the report.