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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
esesmutuesi
New Member

Totals for future dates

Hello,

 

I am lost. I have a measure that calculates the 'expected' sales for future dates. For each date i take the average of last 4 weeks on the same weekday. So for next Monday I will use the sales of last 4 mondays. The measure works fine, but ofcourse as nothing new in DAX the total is not adding up (for the week/month). I have tried everything. Below is an example of measure.

 

Expected Sales=
var selected_date = SELECTEDVALUE('Dim Date'[Date])
var selected_weekday = SELECTEDVALUE('Dim Date'[WeekDay])
var value_ =
 IF( selected_date >= TODAY(),  CALCULATE( [sales],  FILTER(ALL('Dim Date'), selected_weekday = 'Dim Date'[WeekDay] && 'Dim Date'[Last 4 Weeks] = 1)),   CALCULATE( [Compensation], 'Dim Date'[Date] > selected_date -28 && selected_weekday = 'Dim Date'[WeekDay])) / 4
 return
 SUMX('Dim Date', value_)
 
Any help is appreciated!
1 REPLY 1
amitchandak
Super User
Super User

@esesmutuesi ,

 

Have these new columns in Date Table, Week Rank is Important in Date/Week Table

Week Rank = RANKX('Date','Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX('Date','Date'[Year Week],,ASC,Dense) //YYYYWW format

 

 

Last 4 weeks = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-3 && 'Date'[Week Rank]<=max('Date'[Week Rank]) &&  'Date'[Weekday]=max('Date'[Weekday]) ))

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.