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
Anonymous
Not applicable

Calculate average based on weeks

The following returns the number of sales for week 1 by poduct:

 

COUNTX(CALCULATETABLE('SALES REPORT','SALES REPORT'[WEEK NUM]=1),[Count of Gross Sales]) 

 

1. I would like to create a calculation that shows the average of all (52) weeks

 

2. I would also like to reate a moving average of the last 4 weeks. 

3 REPLIES 3
Anonymous
Not applicable

Mate, forget about creating what you want without a proper DATE TABLE. You can't do this based only on the fact table.

 

I'll give you a hint. Try to post a full description of the model and, if possible, also some sample data.

 

Best

Darek

Anonymous
Not applicable

@Anonymous, I do have a proper date table set up

 

Anonymous
Not applicable

You do?

 

Well, it does not look like that at all. Your measure 

 

COUNTX(
CALCULATETABLE(
'SALES REPORT',
'SALES REPORT'[WEEK NUM] = 1
),
[Count of Gross Sales]
)

does not use the Date table to move back and forth in time. It uses some WEEK NUM that's stored in your fact table. Please try to understand that if you go against the rules of proper design, you're shooting yourself in the foot.

 

But it's your call... 🙂

 

 

Best

Darek

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.

Top Solution Authors