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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Reddyp
Helper I
Helper I

Ave. Weekly Sales (6wks)

Need help in DAX formula for Ave. Weekly Sales (6wks)

I have "date column" and "last week sales"  and "quantity"

1 ACCEPTED SOLUTION
v-kkf-msft
Community Support
Community Support

Hi @Reddyp ,

 

Please try the measure.

 

Ave. Weekly Sales = 
VAR startdate = MAX ( 'Calendar'[Date] ) - 6 - 5 * 7
VAR enddate = MAX ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        AVERAGE ( 'Table'[last week sales] ),
        FILTER (
            ALLSELECTED ( 'Calendar' ),
            'Calendar'[Date] >= startdate
                && 'Calendar'[Date] <= enddate
        )
    )

vkkfmsft_1-1654741838750.png

vkkfmsft_0-1654741822567.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-kkf-msft
Community Support
Community Support

Hi @Reddyp ,

 

Please try the measure.

 

Ave. Weekly Sales = 
VAR startdate = MAX ( 'Calendar'[Date] ) - 6 - 5 * 7
VAR enddate = MAX ( 'Calendar'[Date] )
RETURN
    CALCULATE (
        AVERAGE ( 'Table'[last week sales] ),
        FILTER (
            ALLSELECTED ( 'Calendar' ),
            'Calendar'[Date] >= startdate
                && 'Calendar'[Date] <= enddate
        )
    )

vkkfmsft_1-1654741838750.png

vkkfmsft_0-1654741822567.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@Reddyp , You need to have columns like these in you date table

 

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

Avg Last 6 weeks = CALCULATE(Averagex(Values('Date'[Week Rank]), [orders ]) , FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-6 && 'Date'[Week Rank]<=max('Date'[Week Rank])))

 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
https://www.youtube.com/watch?v=pnAesWxYgJ8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.