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
Gabry
Super User
Super User

Total per month / average per month

Hello,

I searched on the forum but I still didn't understand how to solve my issue.

 

I would like to calculate the total quantity ordered by month, then get the average quantity ordered per month

 


This is my Sales table:

 

Gabry_0-1668124817076.png

 

How can I create a measure that calculate the average quantity ordered per month?

 

Thank you guys

 

1 ACCEPTED SOLUTION
Gabry
Super User
Super User

Hi Guys, thank you all for the replies. Last night I was confused and my issue was logical.

 

The average quantity ordered per month is a single value, and can't be splitted into single rows of a column. It's just one single value, to obtain it you have to divide the Total Orders by the number of months.

So my DAX formula is as simple as: 

Total Orders by month = CALCULATE([Total Orders], GROUPBY('Calendar','Calendar'[Year Month]))
 
But now I'm wondering, what if in the calendar there are months where there have been no orders?
I shouldn't be dividing by all the months of the calendar but only by the month in which there started to be orders.
 
 
thank you
 
I came up with a solution but I don't think it's very elegant
 
1) Create a new column in the Purchase table,
Purchased Month = FORMAT(Purchase[PurchaseDate], "YYYY MM")
2) Count the number of month in that column = 
Number of months with purchase = DISTINCTCOUNT(Purchase[Purchased Month])
3)  Calculate the average quantity per month = 
AVG Quantity per Month2 = DIVIDE([Total Orders], [Number of months with purchase])
 
Here is my solution: 
 
 
 
 
 

View solution in original post

5 REPLIES 5
Gabry
Super User
Super User

Hi Guys, thank you all for the replies. Last night I was confused and my issue was logical.

 

The average quantity ordered per month is a single value, and can't be splitted into single rows of a column. It's just one single value, to obtain it you have to divide the Total Orders by the number of months.

So my DAX formula is as simple as: 

Total Orders by month = CALCULATE([Total Orders], GROUPBY('Calendar','Calendar'[Year Month]))
 
But now I'm wondering, what if in the calendar there are months where there have been no orders?
I shouldn't be dividing by all the months of the calendar but only by the month in which there started to be orders.
 
 
thank you
 
I came up with a solution but I don't think it's very elegant
 
1) Create a new column in the Purchase table,
Purchased Month = FORMAT(Purchase[PurchaseDate], "YYYY MM")
2) Count the number of month in that column = 
Number of months with purchase = DISTINCTCOUNT(Purchase[Purchased Month])
3)  Calculate the average quantity per month = 
AVG Quantity per Month2 = DIVIDE([Total Orders], [Number of months with purchase])
 
Here is my solution: 
 
 
 
 
 
Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table with calculated column formulas for Year, Month name and month number.  Sort the Month name by the Month number.  Create a slicer and select a Year.  To your visual, drag Month from the Calendar Table.  Write this measure and drag it to the visual

Total quantity sold = sum(Data[Quantity])

Write this measure and drag it to a card visual

Average quantity sold = SUMX(VALUES(Calendar[Month name]),[Total quantity sold])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @Gabry ,

 

According to your description, here are my steps you can follow as a solution.

(1)This is my test data.

vtangjiemsft_0-1668133287972.png

 

(2)Create a matrix,and you will see:

vtangjiemsft_0-1668133111483.png

For the related .pbix file,pls see attached.

 

You can refer to the following posts that may be helpful to you:

Solved: Calculate average count per month - Microsoft Power BI Community

Solved: Running Total and calculating the average for the ... - Microsoft Power BI Community

Solved: Compare Total per month vs average per month per y... - Microsoft Power BI Community

 

Best Regards,

Neeko Tang

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

ryan_mayu
Super User
Super User

could you pls provide the pbix file or provide the sample data not the screenshot.





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

Proud to be a Super User!




Gabry
Super User
Super User

Also, this is my calendar table:

 

Gabry_0-1668124915678.png

 

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.