Forum Discussion

vishnuprashanth's avatar
vishnuprashanth
Icon for Helper III rankHelper III
8 years ago
Solved

calculate average across columns for all the selected data

I have a dataset with 80 columns. 

I have filtered the necessary columns and I am trying to calculate the average for across each column for the selected data.

DATASET:

athletetime (mm:ss)Tot EnergyEnergy DiffTotal Dist (m)Acc EVDec EVv<8.00km/h8.00<v<14.40km/h14.40<v<19.60km/h19.60<v<24.00km/h24.00<v<30.00km/hv>30.00km/hmax v (km/h)max P (W/kg)
AKLIOUCHE MAGHNES06:1942219%90002291386.5152.870.10023.2459.55
ARLOTTI ALESSANDRO93:19:0074933147%169488337290.16533.62345.8632.5145.6028.09588.675
BOUREBABA ZINEDDINE14:221592228%330927921.81519.4766.890.510.6025.2570.245
DECARPENTRIE VALENTIN70:47:003307572%724515203008.12592.3983.3462.4197.60.930.04111.29

 

OUTPUT EXPECTED:

 

AverageNaN32037.750.647100.56.2515.52877.752757.951062.175313.87588.450.22526.6562582.44

 

I could achieve this in Excel by the below formula and by dragging it for all my columns. I want to do the same in Power BI.

=AVERAGE(C1:C4)

Output expected in Power BI: 


Output in Power BI

 

  • Hi vishnuprashanth

    1. select columns from “Total Energy” to the last one except “athlete” and “time (mm:ss)”

        click Transform->unpivot columns

     

    2. Close and apply, then come back to data model view, create a new table

    Table1 = SUMMARIZE(FILTER(Sheet1,[athlete]="AKLIOUCHE MAGHNES"),[Attribute],[avg],[time (mm:ss)],[Value],"as","z-avgall")

     

     

    3. Union two tables

    Table2 = UNION(Sheet1,Table1)

     

    4. Finally, in Report View, use matrix as below

     

    Here is my pbix

     

    Best Regards

    Maggie

     

     

2 Replies

  • v-juanli-msft's avatar
    v-juanli-msft
    Icon for Community Support rankCommunity Support

    Hi vishnuprashanth

    1. select columns from “Total Energy” to the last one except “athlete” and “time (mm:ss)”

        click Transform->unpivot columns

     

    2. Close and apply, then come back to data model view, create a new table

    Table1 = SUMMARIZE(FILTER(Sheet1,[athlete]="AKLIOUCHE MAGHNES"),[Attribute],[avg],[time (mm:ss)],[Value],"as","z-avgall")

     

     

    3. Union two tables

    Table2 = UNION(Sheet1,Table1)

     

    4. Finally, in Report View, use matrix as below

     

    Here is my pbix

     

    Best Regards

    Maggie

     

     

    • vishnuprashanth's avatar
      vishnuprashanth
      Icon for Helper III rankHelper III

      Thank you so much v-juanli-msft

      I just tried this and it works perfectly. 

      I also found an alternate solution by creating HASONEVALUE function for each column and adding it to the report as a separate table. But your solution works better and is comparatively easier. thanks again :)