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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
carguello726
Frequent Visitor

Getting correct Average Sales Quantity by Week when data is blank

Hi,

 

I am trying to capture the average sales quantity per week by product. The challenge is to include the weeks when there is no data.

 

I know that i will  need to use ALL or VALUES for the week # but I still cannot get the desired result. In the example below, both products should take an average accross 3 weeks, even though product B does not have any sales (row item)  in week 3 - a zero should be placed in week 3. Any help is greatly appreciated. Thank you.

Capture.JPG

 

 

 

4 REPLIES 4
v-yingjl
Community Support
Community Support

Hi @carguello726 ,

Im not certain the structure of your table so I can provide two ways for this case:

If the table structure is like this, you can create the following measure simply:

AVG Qty = SUM('Table'[Quantity])/ 3

 assume the week is 3 or more than 3 but have no whole row data in table, just modify the denominatorassume the week is 3 or more than 3 but have no whole row data in table, just modify the denominator

If the table structure is like this, you can create the following measure:

AVG Qty = SUM('Table'[Quantity])/ CALCULATE(DISTINCTCOUNT('Table'[Week #]),ALLSELECTED('Table'))

in this way the denominator is dynamicin this way the denominator is dynamic

This may be your expected output:

average.png

Best Regards,

Yingjie Li

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

Thank you so much. My table is like your first example where the week (entire row) is missing.

 

I would prefer to have a dax function that uses the AVERAGE function instead of manually inputting the denominator. This is because I will also need to capture standard deviation (which will need to include the missing week).

Hi @carguello726 ,

I dont think Average function can match for this case since the entire row is missing. You can also use the second measure to get the same result. If you want to calculate standard deviation, you can set the measure result as a variable to use.

 

Best Regards,

Yingjie Li

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Community Champion
Community Champion

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.