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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
ategally
Frequent Visitor

This Week and Last Week

I need to create a base derivative for This Week and Last Week so I can add this to any base measure to give for example Sales for This Week or Sales for Last Week.

 

Please help.

5 REPLIES 5
Anonymous
Not applicable

Hi @ategally,

 

I think weeknum function will suitable for your requirement.

 

Reference link:

WEEKNUM Function (DAX)

Custom Week filter

 

Regards,

Xiaoxin Sheng

Hi @Anonymous

 

Thank you for your response.  Greatly appreciated.

 

However I came up with this and not sure how to apply this to say the Sales measure:

 

[IsInCurrentYear] =if(YEAR(NOW())= [Dates[Calendar Year],1,0)



--This Week
 
 [This Week] =if([isInCurrentYear] && WEEKNUM(NOW())=[Dates[Week Year No],1,0)

--Last Week
 
 [Last Week] =if([isInCurrentYear] && (WEEKNUM(NOW())-1)=[Dates[Week Year No],1,0)

 

 

Kindest regards

Anonymous
Not applicable

HI @ategally,

 

 

Maybe you can take a look at below formula:

This Week Sales =
CALCULATE (
    SUM ( table[Sales] ),
    FILTER (
        ALL ( Date ),
        YEAR ( Date[Date] ) = YEAR ( TODAY () )
            && WEEKNUM ( Date[Date], 1 ) = WEEKNUM ( TODAY (), 1 )
    )
)

Last Week Sales =
CALCULATE (
    SUM ( table[Sales] ),
    FILTER (
        ALL ( Date ),
        YEAR ( Date[Date] ) = YEAR ( TODAY () )
            && WEEKNUM ( Date[Date], 1 ) = WEEKNUM ( TODAY (), 1 )-1
    )
)

Regards,

Xiaoxin Sheng

Thank you @Anonymous

 

I have implemented this and all I get is the same data for each day:

 

02/10/2017 00:00:008421206.68822962675.768
13/10/2017 00:00:008421206.68822962675.768
15/10/2017 00:00:008421206.68822962675.768
10/10/2017 00:00:008421206.68822962675.768
12/10/2017 00:00:008421206.68822962675.768
14/10/2017 00:00:008421206.68822962675.768
09/10/2017 00:00:008421206.68822962675.768
11/10/2017 00:00:008421206.68822962675.768
01/01/2017 00:00:008421206.68822962675.768
Anonymous
Not applicable

Hi @ategally,

 

My formulas are measure, I think you use them as the calcualte column,right?

In addition, if you share some sample data, it will be help for analysis.

 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors