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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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

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

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