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

Last Cpmpleted 8 Weeks

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. 

Iklizo_0-1656089327073.png

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

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 )

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

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 )
amitchandak
Super User
Super User

@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])))

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

@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. 

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.