cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
campelliann
Helper I
Helper I

Average monthly sales - daily granularity

Hi, 

 

So I have the following table "Table1"). And I want to get the average sales from the two months, which should be: 31 (total january) + 28 (total february)/ 2 = 29,5

I did sum(Table1[Sales])/Calculate(Distinctcount[Table1[month]), Table1[sales]>=0) - and it worked.

But is there another way? I tried with the averagex(summarize..) without success (how does one even mention the name of the newly summarized virtual column), or averagex(values month), sum sales)and this is giving me the total... 59
Thanks

 

Table1 (sales is always 1 to simplify)

DateSalesMonth
january 11january
january 21january
.....1...
February 281February
2 ACCEPTED SOLUTIONS
Fowmy
Super User IV
Super User IV

@campelliann 

You can create a measure as :

Sales average per Month = 
AVERAGEX(
	VALUES('Table1'[Month]),
	CALCULATE(SUM('Table1'[Sales]))
)



Did I answer your question? Mark my post as a solution! and hit thumbs up


Blog - Data Visualization

Website   YouTube    LinkedIn   PBI User Group

View solution in original post

@Fowmy , you are brilliant :). The values approach was not working, because I was not using calculate around the sum. You need the calculate to "activate" a sort of filter context row by row, right? 
Other wise I get always the total sum of the table, thus the average being the total.

View solution in original post

3 REPLIES 3
Vera_33
Solution Sage
Solution Sage

Hi @campelliann 

 

If you need SUMMARIZE, you need variable, but performance wise, no need to do it

 

Just to show you, using GROUPBY, but it is not recommended in this case

avg2 = 
VAR T1 = GROUPBY(Table1,Table1[Month],"SALES", SUMX(CURRENTGROUP(),Table1[Sales]))
RETURN
AVERAGEX(T1,[SALES])

 

simply do it is quicker

avg = SUM(Table1[Sales])/COUNTROWS(VALUES(Table1[Month]))
Fowmy
Super User IV
Super User IV

@campelliann 

You can create a measure as :

Sales average per Month = 
AVERAGEX(
	VALUES('Table1'[Month]),
	CALCULATE(SUM('Table1'[Sales]))
)



Did I answer your question? Mark my post as a solution! and hit thumbs up


Blog - Data Visualization

Website   YouTube    LinkedIn   PBI User Group

View solution in original post

@Fowmy , you are brilliant :). The values approach was not working, because I was not using calculate around the sum. You need the calculate to "activate" a sort of filter context row by row, right? 
Other wise I get always the total sum of the table, thus the average being the total.

View solution in original post

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors