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

dax week-to-date last week as a variable

hi,

 

i have a dax measure for week-to-date (WTD) as follows:

   WTD =
   VAR CurrentDate = LASTDATE( 'Calendar'[Date] )
   VAR WeekDayNo = WEEKDAY( LASTDATE( 'Calendar'[Date]), 3)
   RETURN
      CALCULATE(
      SUM( Sales[Amount] ),
      DATESBETWEEN(
         'Calendar'[Date],
            DATEADD(
         CurrentDate,
         -1*WeekDayNo,
         DAY),
         CurrentDate)
         )
 
i also managed to create a dax measure for week-to-date for the previous week (WTD.LW) as follows:

   WTD.LW = CALCULATE (
      WTD,
         DATEADD (
         'Calendar'[Date],
         -7,
         DAY
         )
      )

however, if i wish to create week-to-date for the previous week (i.e. WTD.LW) as a variable, please advise on how to do so. 
tks, -nik
 
p.s.
my attempt to use the following dax still results in  week-to-date (WTD):

   VAR CurrentDate = LASTDATE( 'Calendar'[Date] )
   VAR WeekDayNo = WEEKDAY( LASTDATE( 'Calendar'[Date]), 3)
   VAR CWTD = CALCULATE(
     SUM( Sales[Amount],
         DATESBETWEEN(
         'Calendar'[Date],
            DATEADD(
            CurrentDate,
            -1*WeekDayNo,
            DAY),
            CurrentDate)
            )
      RETURN
         CALCULATE(
            CWTD,
            DATEADD (
            'Calendar'[Date],
            -7,
            DAY))

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , please refer if my blogs on the same can help

Power BI — WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123

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

View solution in original post

v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create measures like DAX below.

 

WTD =
CALCULATE (
    SUM ( Sales[Amount] ),
    FILTER (
        ALL ( 'Calendar' ),
        WEEKNUM ( 'Calendar'[Date] ) = WEEKNUM ( MAX ( 'Calendar'[Date] ) )
            && WEEKDAY ( 'Calendar'[Date] ) <= WEEKDAY ( MAX ( 'Calendar'[Date] ) )
    )
)



LWTD =
CALCULATE (
    SUM ( Sales[Amount] ),
    FILTER (
        ALL ( 'Calendar' ),
        WEEKNUM ( 'Calendar'[Date] )
            = WEEKNUM ( MAX ( 'Calendar'[Date] ) ) - 1
            && WEEKDAY ( 'Calendar'[Date] ) <= WEEKDAY ( MAX ( 'Calendar'[Date] ) )
    )
)

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create measures like DAX below.

 

WTD =
CALCULATE (
    SUM ( Sales[Amount] ),
    FILTER (
        ALL ( 'Calendar' ),
        WEEKNUM ( 'Calendar'[Date] ) = WEEKNUM ( MAX ( 'Calendar'[Date] ) )
            && WEEKDAY ( 'Calendar'[Date] ) <= WEEKDAY ( MAX ( 'Calendar'[Date] ) )
    )
)



LWTD =
CALCULATE (
    SUM ( Sales[Amount] ),
    FILTER (
        ALL ( 'Calendar' ),
        WEEKNUM ( 'Calendar'[Date] )
            = WEEKNUM ( MAX ( 'Calendar'[Date] ) ) - 1
            && WEEKDAY ( 'Calendar'[Date] ) <= WEEKDAY ( MAX ( 'Calendar'[Date] ) )
    )
)

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

many2 tks, @v-xicai  & @amitchandak .

krgds, -nik

amitchandak
Super User
Super User

@Anonymous , please refer if my blogs on the same can help

Power BI — WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123

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