Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
Hi All,
I'm still struggling on how to calculate the Avg/Day for The sum of Last completed 8weeks
. The code works but, when i remove the weeknum & add another attribute it goes blank. see DAX below.
Solved! Go to Solution.
Hi @Anonymous
please try
Avg/Day Last 8 Weeks =
VAR currentweek =
WEEKNUM ( TODAY () + 250 )
VAR Firstweek = currentweek - 8
VAR Requireweeks =
FILTER (
VALUES ( 'Sales '[Fiscal Week] ),
'Sales '[Fiscal Week] >= Firstweek
&& 'Sales '[Fiscal Week] < currentweek
)
RETURN
SUMX ( Requireweeks, [Unit Sold CY] / 7 )
Hi @Anonymous
please try
Avg/Day Last 8 Weeks =
VAR currentweek =
WEEKNUM ( TODAY () + 250 )
VAR Firstweek = currentweek - 8
VAR Requireweeks =
FILTER (
VALUES ( 'Sales '[Fiscal Week] ),
'Sales '[Fiscal Week] >= Firstweek
&& 'Sales '[Fiscal Week] < currentweek
)
RETURN
SUMX ( Requireweeks, [Unit Sold CY] / 7 )
@Anonymous , need new columns as per need
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 8 weeks = CALCULATE(Averagex(Values('Date'[Week Rank]), [orders ]) , FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-8 && 'Date'[Week Rank]<=max('Date'[Week Rank])))
@amitchandak What i need is from the current week, i need last complated 8 weeks Total. Eg. let's say the current week is week 9, i want the total from week 8 to 1. the measure you provided only gives me week 8.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
11 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
12 | |
11 | |
11 | |
11 |