Forum Discussion

P_P2595's avatar
P_P2595
Helper I
3 years ago
Solved

Calculating variance from multiple columns from the same table

Hi Team,

I have the below input and want to calculate variance based on the description column. also want the output to be in table or matrix form.

Input:

iddescriptionsymptomsconduct_problemhyperactivityproblemprosocialimpactscore
150 Start471086415
150End3584777
160Start735741018
160Start55562816
160End55562613
160End54492818
164 Start722561019
164End54258714
173 Start971074410
173End8797298
188 Start7370969
188End73506516
189 Start681057412
189End46947211

Expected output:

ScaleStartEnddiff
symptoms6.435.291.14
conduct_problem5.004.860.14
hyperactivity7.006.001.00
problem5.435.000.43
prosocial5.434.860.57
impact6.576.290.29
score14.1412.431.71
all Total50.0044.715.29

 

Please not that the value of Start and End is the average value based on id column. and the all Total is the summantion of the 7 rows.

Is this possible in power bi?

 

Thanks in advance.

4 Replies

  • P_P2595 , Unpivot the all column other than Id and description , then you can have measures like

     

    M1 = calculate(Average(Table[Value]), filter(Table, Table[Description] ="Start") )

     

    M2= calculate(Average(Table[Value]), filter(Table, Table[Description] ="End") )

     

    Diff = [M1] -[M2]

     

    Learn Power BI: Power Query UnPivot Data, Pivot Data, Transpose Data, Query Fill Up, Fill Down: https://www.youtube.com/watch?v=cN8AO3_vmlY&t=36407s

     

    Unpivot Data(Power Query): https://youtu.be/2HjkBtxSM0g

  • Hi all,
    Thanks for your solutions and it’s working for me. Is it possible to get the same output without unpivoting the columns as I have some pages and visuals with that table and extra columns than the input data and I don't want to unpivot the data because it's affecting other pages and visuals.
    Is there any other way to get the expected output by creating a measure and calculated column?
    Thank you so much.
    Greatly appreciate your answers.