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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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]) ))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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