Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Need help in calculating standard deviation using custom column

Dear All,

 

I would like to calcuate standard devation on below data using Custom column, please help I'm new to Power BI tool. Data looks like below

 

Source Data:

SiteCodeDAY_DATEDAYS
YPYPSL15204Jul2015 0:00:000
YPYPSL15212Jul2015 0:00:00-8
YPYPSL15210Aug2015 0:00:00-29
YPYPSL15212Dec2015 0:00:00-124
YPYPSL15214Dec2015 0:00:00-2
YPYPSL15217Jun2016 0:00:00-186
YPYPSL15219Dec2016 0:00:00-185
YPYPSL15222Dec2016 0:00:00-3
YPYPSL15221Feb2017 0:00:00-61
CGCG15511May2015 0:00:000
CGCG15511May2015 0:00:000
KBKB15518Dec2015 0:00:000
KBKB15514Feb2016 0:00:0058
KBKB15523Dec2016 0:00:00313
KBKB15520Dec2017 0:00:00362
KBKB15518Dec2015 0:00:000
KBKB15514Feb2016 0:00:00-58
KBKB15523Dec2016 0:00:00-313
KBKB15520Dec2017 0:00:00-362
FE 23Nov2017 0:00:000
FE 27Nov2017 0:00:004
FE 26Apr2018 0:00:00150
FE 23Nov2017 0:00:000
FE 27Nov2017 0:00:00-4
FE 26Apr2018 0:00:00-150

 

Expected Output:

SiteCodeSTD_OF_DAYS
YPYPSL152102.231571
CGCG1550
KBKB155257.6692232
FE 94.90205477

 

I have tried using Transform --> Statitistcs --> Standard Devatation which didn't worked for me. please guide mw how can i get expected out put as parked above.

 

In case of any more information required please do let me know, Thanks in advance for you help.

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Please try below Power Query.

let
    Source = Excel.Workbook(File.Contents("C:\Users\xxxx\Desktop\Sample Data (Autosaved) (Autosaved).xlsx"), null, true),
    data_Sheet = Source{[Item="data",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(data_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Site", type text}, {"Code", type text}, {"DAY_DATE", type datetime}, {"DAYS", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Site", "Code"}, {{"standard deviation", each List.StandardDeviation([DAYS]), type number}})
in
    #"Grouped Rows"

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Please try below Power Query.

let
    Source = Excel.Workbook(File.Contents("C:\Users\xxxx\Desktop\Sample Data (Autosaved) (Autosaved).xlsx"), null, true),
    data_Sheet = Source{[Item="data",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(data_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Site", type text}, {"Code", type text}, {"DAY_DATE", type datetime}, {"DAYS", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Site", "Code"}, {{"standard deviation", each List.StandardDeviation([DAYS]), type number}})
in
    #"Grouped Rows"

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Stachu
Community Champion
Community Champion

in PowerBI Modelling tab you can create this measure:
STD_OF_DAYS = STDEV.P('Source Data'[DAYS])
it gives values different than i your expected result- did you put dummy data there?



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

TomMartens
Super User
Super User

Hey,

 

using the DAX function STDEV.S by creating a measure like so:

Measure = 
CALCULATE(
    STDEV.S('Table2'[DAYS])
)

creates this output:

image.png

 

Here you will find guidance how to create a measure:

https://docs.microsoft.com/en-us/power-bi/desktop-tutorial-create-measures

 

And here is something about the DAX function STDEV.S
https://msdn.microsoft.com/en-us/query-bi/dax/stdev-s-function-dax

Hopefully this gets you started

 

Regards

Tom

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

Thanks Tom & Stachu for your reply, I want same kind of logic to be done under query editor --> Custom Column because I need that result in a new column so that i can build rest of logic on top of it.

 

Stachu - It's actual standard devation data source & Expected output which is implemented in diff tool which we are migrating in power bi.

Stachu
Community Champion
Community Champion

so you want to group the table with a new column calculating stadard deviation?

one more question - is the output you showed based on exacly same dataset that you posted? When I calculate the standard deviation I get the same results as the ones that @TomMartens has posted, which are not consistent with your outcome (see YP site)



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

Yes I want to group the table with a new column for calcuating standard deviation.

 

Dear Stachu / Tom please help me.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.