Forum Discussion
average year sales
Hi All,
i need your help to calculate the average sales during fyscal year for each item, for example item A sold 1000 euro in 12 month, average 83,33 euro, how i can divide the total sales for the month where the item sold?
To calculate the average sales per month during a fiscal year in Power BI, but only for the months where the item actually had sales, you can use a DAX measure. This measure will:
- Calculate the total sales for the fiscal year.
- Count the number of months where there were sales for that item.
- Divide the total sales by the number of months with sales.
Here’s how you can write the DAX measure:
Steps:
- Total Sales: Sum the sales for the item.
- Number of Months with Sales: Count the distinct months where sales occurred.
- Average Sales Per Month: Divide the total sales by the count of months with sales.
DAX Formula:
DAXCopy codeAverage Sales Per Month = VAR SalesMonths = CALCULATE( COUNTROWS( DISTINCT(Sales[Month]) ), Sales[Total Sales] > 0 -- Only count months where there were sales ) VAR TotalSales = SUM(Sales[Total Sales]) -- Total sales of the item RETURN IF( SalesMonths > 0, TotalSales / SalesMonths, -- Calculate average if there are sales months 0 -- Return 0 if there were no sales )
3 Replies
- 123abcCommunity Champion
To calculate the average sales per month during a fiscal year in Power BI, but only for the months where the item actually had sales, you can use a DAX measure. This measure will:
- Calculate the total sales for the fiscal year.
- Count the number of months where there were sales for that item.
- Divide the total sales by the number of months with sales.
Here’s how you can write the DAX measure:
Steps:
- Total Sales: Sum the sales for the item.
- Number of Months with Sales: Count the distinct months where sales occurred.
- Average Sales Per Month: Divide the total sales by the count of months with sales.
DAX Formula:
DAXCopy codeAverage Sales Per Month = VAR SalesMonths = CALCULATE( COUNTROWS( DISTINCT(Sales[Month]) ), Sales[Total Sales] > 0 -- Only count months where there were sales ) VAR TotalSales = SUM(Sales[Total Sales]) -- Total sales of the item RETURN IF( SalesMonths > 0, TotalSales / SalesMonths, -- Calculate average if there are sales months 0 -- Return 0 if there were no sales ) - 123abcCommunity Champion
To calculate the average sales per month during a fiscal year in Power BI, but only for the months where the item actually had sales, you can use a DAX measure. This measure will:
- Calculate the total sales for the fiscal year.
- Count the number of months where there were sales for that item.
- Divide the total sales by the number of months with sales.
Here’s how you can write the DAX measure:
Steps:
- Total Sales: Sum the sales for the item.
- Number of Months with Sales: Count the distinct months where sales occurred.
- Average Sales Per Month: Divide the total sales by the count of months with sales.
DAX Formula:
DAXCopy codeAverage Sales Per Month = VAR SalesMonths = CALCULATE( COUNTROWS( DISTINCT(Sales[Month]) ), Sales[Total Sales] > 0 -- Only count months where there were sales ) VAR TotalSales = SUM(Sales[Total Sales]) -- Total sales of the item RETURN IF( SalesMonths > 0, TotalSales / SalesMonths, -- Calculate average if there are sales months 0 -- Return 0 if there were no sales ) - Mike91Helper I
Thanks a lot for your help 🙂 all works