cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
alekskr Frequent Visitor
Frequent Visitor

DAX sum of square of weekly sales

Hi. 

I have a measure [Sales Quantity2] that is defined as the sum of a column Sales[Quantum].

Now I want to calculate the std.dev and mean of [Sales Quantity2] for a given period. Week by week. The mean is easy, just calculate [Sales Quantity2] divided by number of weeks. 

To calculate the std.dev I need to sum up quantum for an entire week, square it, and then sum over weeks. How to do this?Capture.PNG

I.e. need to make a measure that can sum up SQ3 in this table

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Stachu Super Contributor
Super Contributor

Re: DAX sum of square of weekly sales

can you post sample anonymised data?

in general I'd go with STDEVX.P or STDEVX.S  & SUMMARIZE
https://docs.microsoft.com/en-gb/dax/stdevx-s-function-dax

Measure =
STDEVX.S (
    ADDCOLUMNS ( SUMMARIZE ( Table, Table[Week No] ), "SQ2", [Sales Quantity2] ),
    [SQ2]
)

you would need to adjust blue description and maybe replace STDEVX.S with STDEVX.P

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

2 REPLIES 2
Highlighted
Stachu Super Contributor
Super Contributor

Re: DAX sum of square of weekly sales

can you post sample anonymised data?

in general I'd go with STDEVX.P or STDEVX.S  & SUMMARIZE
https://docs.microsoft.com/en-gb/dax/stdevx-s-function-dax

Measure =
STDEVX.S (
    ADDCOLUMNS ( SUMMARIZE ( Table, Table[Week No] ), "SQ2", [Sales Quantity2] ),
    [SQ2]
)

you would need to adjust blue description and maybe replace STDEVX.S with STDEVX.P

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

View solution in original post

alekskr Frequent Visitor
Frequent Visitor

Re: DAX sum of square of weekly sales

Worked great. Thanks Smiley Happy

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 117 members 1,541 guests
Please welcome our newest community members: