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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jazking123
Frequent Visitor

Aggregating daily data.

I am trying to aggregate my daily frequency data into weeks and then calculate an average of weekly sales.

 

So the average-average for the following data would be

 

Week

Sales

1

50

1

65

2

52

2

63

3

12

3

16

 

Week 1: 50+65 = 115

Week 2: 52 + 63 = 115

Week 3: 12 + 16 = 28

 

Average Sales by week = 86.

 

It's important that I calculate it this way as I'd like to use the VAR.S command to calculate the variance of Weekly Sales.

 

Thanks for any assistance,

 

Regards,

 

Gareth.

 

 

 

 

 

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @jazking123

 

HEre is one way (of a few) that you can do it

 

 

 

Sales2 = IF(
				ISFILTERED('Table1'[Week]), 
				CALCULATE(SUM('Table1'[Sales])),
				DIVIDE
					(
						SUM(Table1[Sales]),
						DISTINCTCOUNT('Table1'[Week]))
					)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

2 REPLIES 2
Phil_Seamark
Employee
Employee

Hi @jazking123

 

HEre is one way (of a few) that you can do it

 

 

 

Sales2 = IF(
				ISFILTERED('Table1'[Week]), 
				CALCULATE(SUM('Table1'[Sales])),
				DIVIDE
					(
						SUM(Table1[Sales]),
						DISTINCTCOUNT('Table1'[Week]))
					)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

That's perfect.

 

Thank you sir.

 

*Update*

 

Sadly I think i was mistaken, the reply posted seems to calculate the average value. I need the process to occur in two stages. I'm hoping that the first aggregates by week and the second takes the average of the weeks. I need it to do this so I can calculate the variation between weeks.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.