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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
jj1
Helper II
Helper II

dax sales ytd yoy through today for prior year

Hi

Table 1 is calendar table but so far i did not connect the date table created date with the date calendar date so no relationship with the data table housing sales orders

Measure in place is YTD present year and YTD prior year(using time intelligence)

Goal is not to get year over year only but only year over year through today 

such as sales YTD 2024 is calculated only through 4/20/24 so it compares to sales through YTD 4/20/25 present year

What is cleanest dynamic solutioni tried using var filter then calculate  but no success as it continues to give me april 2024 all month instead of only through april 20, 2024 total

one note is data table has a parsing date column too

calendar table name is Date Table

sales order table name is Sales Table

jj1_0-1745185789154.png

sales table below showing order created date and the 3 measure below using created date 

jj1_2-1745186046880.png

 

jj1_1-1745185851810.png

 

 

1 ACCEPTED SOLUTION
andrewsommer
Super User
Super User

Connect your tables first and get in the habit of using a date table.   Simplist way to get there:

Current Year

Sales YTD Through Today :=
VAR TodayDate = TODAY()
VAR YearStart = DATE(YEAR(TodayDate), 1, 1)
RETURN
CALCULATE(
    SUM('Sales Table'[Sales Amount]),
    DATESBETWEEN('Date Table'[Date], YearStart, TodayDate)
)

 

Prior year to Date:

Sales YTD Through Same Day Last Year :=
VAR TodayDate = TODAY()
VAR LastYearSameDay = TODAY() - 365  // Adjust if leap year logic needed
VAR YearStartLY = DATE(YEAR(LastYearSameDay), 1, 1)
RETURN
CALCULATE(
    SUM('Sales Table'[Sales Amount]),
    DATESBETWEEN('Date Table'[Date], YearStartLY, LastYearSameDay)
)

 

Please mark this post as solution if it helps you. Appreciate Kudos.

View solution in original post

2 REPLIES 2
jj1
Helper II
Helper II

now it works-issue was data table needed to have parse date linked to cal datble date not created date linked from data table as the created date data table had been parsed prior

andrewsommer
Super User
Super User

Connect your tables first and get in the habit of using a date table.   Simplist way to get there:

Current Year

Sales YTD Through Today :=
VAR TodayDate = TODAY()
VAR YearStart = DATE(YEAR(TodayDate), 1, 1)
RETURN
CALCULATE(
    SUM('Sales Table'[Sales Amount]),
    DATESBETWEEN('Date Table'[Date], YearStart, TodayDate)
)

 

Prior year to Date:

Sales YTD Through Same Day Last Year :=
VAR TodayDate = TODAY()
VAR LastYearSameDay = TODAY() - 365  // Adjust if leap year logic needed
VAR YearStartLY = DATE(YEAR(LastYearSameDay), 1, 1)
RETURN
CALCULATE(
    SUM('Sales Table'[Sales Amount]),
    DATESBETWEEN('Date Table'[Date], YearStartLY, LastYearSameDay)
)

 

Please mark this post as solution if it helps you. Appreciate Kudos.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.