Forum Discussion
including blanks in an average with summarize
- 8 years ago
Hi,
See if this works
=STDEVX.P(SUMMARIZE(Calendar,Calendar[YearMonth],"MonthlyQtty",sum(Sales[Quantity])),[MonthlyQtty])
hi Ashish,
Done. The Short example lynk is the following
https://drive.google.com/file/d/1_gu410ALDLz1HDkwAdXWknYXciK4fOPw/view?usp=sharing
Rgds.
Hi KeyData,
Try this
=MonthlyAvrgSalesQtty1 = sum(Sales[SalesQuantity])/DATEDIFF(MIN('Calendar'[DateKey]),MAX('Calendar'[DateKey])+1,MONTH)
Hope this helps.
- KeyData8 years agoFrequent Visitor
Do you have any idea why the summary options do not work?
- Ashish_Mathur8 years ago
Super User
- KeyData8 years agoFrequent Visitor
Hi Ashis.
Thanks a lot for your interest. Your solution porpoused of calculate the average like the sum of sales over the count of the months in the data range is correct, but i need a solution with the summarize clause, because another statistical measures are needed. I should have posted this discussion for example with devstat function, wich is more difficult to calculate in an alternative way like the v-shex or your last one.
How can we use the next expression includind in the calculation blanks like 0s.?
SalesStDev= STDEVX.P(SUMMARIZE(Sales,SalesTime[YearMonth],"MonthlyQtty",sum(Sales[Quantity])),[MonthlyQtty])
- Ashish_Mathur8 years ago
Super User
Hi,
See if this works
=STDEVX.P(SUMMARIZE(Calendar,Calendar[YearMonth],"MonthlyQtty",sum(Sales[Quantity])),[MonthlyQtty])
- KeyData8 years agoFrequent Visitor
Hi Ashish
Thanks a lot. That´s the solution. The clause works in the following way
= AVERAGEX(SUMMARIZE('Calendar',Calendar[YearMonth],"MonthlyQtty",IF(ISBLANK(SUM(Sales[SalesQuantity])),0,SUM(Sales[SalesQuantity]))),[MonthlyQtty])
Like you suggested, it´s imperative to invoque the Calendar Table instead the Sales one.
Again, Thank you very much for your interest and your help
- Ashish_Mathur8 years ago
Super User
You are welcome.
- jpt12288 years ago
Responsive Resident
Hello Ashish_Mathur I am trying to replicate your formula suggestion to include blanks in the average. I have a date table (Dimdate) with [weekinyear] granularity for sales. I also have an invoiced lines table (invoicedlines) with [Cases Invoiced]. I need to calculate the value of invoiced cases INCLUDING weeks there are no invoiced cases.
Item A: Sold 1,792 cases over 5 weeks so the result should be: 1,792/10=179.2 But my current calculation is ignoring the zero weeks. So the result it is returning is 1,792/5 = 358.4 which is NOT CORRECT.
Sum of Invoiced Cases Week in year 179.2 Row Labels 31 32 33 34 35 36 37 38 39 40 Grand Total Straight Invoiced for 10 weeks including blanks number of blanks not counting blanks Item A 384 256 256 640 256 1792 179.2 5 358.4 Item B 140 140 180 180 80 40 140 120 180 240 1440 144 0 144 Item C 9450 9412 11886 9273 7453 8385 8768 10542 6574 9502 91245 9124.5 0 9124.5 Item D 1600 800 1760 1097 1360 2320 960 1120 11017 1101.7 2 1377.125 - Ashish_Mathur8 years ago
Super User
Hi,
Share the link from where i can download your PBI file. Please ensure that the file size is only a couple of MB's.
- jpt12288 years ago
Responsive Resident
Ashish_Mathur Hello, I cannto share the PBI file - it is connected to a large data model with sensitive data.