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
Mahmed1
Helper IV
Helper IV

Why Is there no Week To Date? Calculate same period last week Fiscal Petiod

Hi Guys

 

Im not sure why we dont have a WTD function compared with YTD, MTD etc...


I want to be able to select the start of Week from my Fiscal calender (Starts in April)

and then want the sales for the

Week Selected and also the sales for same period last week

 

so say im only 4 days into the current week (Thursday) and i select Week commencing the 09/01

i need a measure that returns last week up until last Thursday too so same period last week as well as current week to date

 

how can I achieve this the best way bearing in mind the fiscal year (I do hasve an IsoWeek number column)

 

thank you

7 REPLIES 7
Mahmed1
Helper IV
Helper IV

@ppm1 Thank you

ppm1
Solution Sage
Solution Sage

These expressions show one way to do it, but you'll have to adapt to get your fiscal week.

 

ppm1_0-1673659913509.png

 

WTD =
VAR thisdate =
    MAX ( 'Date'[Date] )
VAR SOW =
    thisdate - WEEKDAY ( thisdate ) + 1
RETURN
    CALCULATE (
        [Total Sales],
        ALL ( 'Date' ),
        'Date'[Date] >= SOW
            && 'Date'[Date] <= thisdate
    )

PWTD =
VAR thisdate =
    MAX ( 'Date'[Date] ) - 7
VAR SOW =
    thisdate - WEEKDAY ( thisdate ) + 1
RETURN
    CALCULATE (
        [Total Sales],
        ALL ( 'Date' ),
        'Date'[Date] >= SOW
            && 'Date'[Date] <= thisdate
    )

 

Pat

 

Microsoft Employee

Thank you

 

really appreciate it

 

this could work as i have a start of week column in my date table

 

My date table has future dates in there too so am i right in saying it would be better to get 'Thisdate' by using the MaxDate of SalesTable rather than DateTable?

Greg_Deckler
Community Champion
Community Champion

@Mahmed1 You'll have to create a week # column since it is a fiscal year and not a standard calendar year. Unless your weeks line up, then you can use WEEKNUM and grab all the dates with the same WEEKNUM that are less than TODAY. Hard to say without example data but generally you build helper columns into your date table. I have an example here that includes week #:

DAX Custom 445 Calendar - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi,

 

i tried this but when comparing to previous week for same period last week it does not work

 

Sales_PW =

 

VAR CurrentWeekNum = SELECTEDVALUE(calender([Fiscal_Week_Num]))

 

VAR CurrentYear = SELECTEDVALUE(calender[Fiscal_Year])

 

VAR MaxWeekNum = CALCULATE(

MAX(calender[Fiscal_Week_Num]),

ALL(calender))

 

RETURN

 

SUMX(

            FILTER(ALL(calender),

                       IF(CurrentWeekNum = 1,

                         calender[Fiscal_Week_Num] = MaxWeekNum && calender[Fiscal_Year]= CurrentYear - 1),

 

calender[Fiscal_Week_Num] = CurrentWeekNum - 1 && calender[Fiscal_Year]= CurrentYear)),

[Total_Sales])

hi  @Mahmed1

you code seems having some issue,  try to change it like this:

Sales_PW =
VAR CurrentWeekNum = SELECTEDVALUE(calender([Fiscal_Week_Num]))
VAR CurrentYear = SELECTEDVALUE(calender[Fiscal_Year])
VAR MaxWeekNum = 
CALCULATE( AX(calender[Fiscal_Week_Num]), ALL(calender))
RETURN
SUMX(
    FILTER(
        ALL(calender),
        IF(
            CurrentWeekNum = 1,
            calender[Fiscal_Week_Num] = MaxWeekNum 
                && calender[Fiscal_Year]= CurrentYear - 1,
        calender[Fiscal_Week_Num] = CurrentWeekNum - 1 
            && calender[Fiscal_Year]= CurrentYear)
        )
    ),
    [Total_Sales]
)
 
p.s. please consider @someone, if you seek further suggestions. 

 

Thank you for getting back to me..I do have a WeekNum column that starts from 01/04 and also a StartOfWeek date column

 

I need to now get WTD sales if i select this week and also week to date last week/same period last week

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.