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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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
Stachu
Community Champion
Community Champion

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!
Thank you for the kudos 🙂

View solution in original post

2 REPLIES 2
Stachu
Community Champion
Community Champion

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!
Thank you for the kudos 🙂

Anonymous
Not applicable

Worked great. Thanks 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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