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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jamuka
Advocate II
Advocate II

DATESYTD doesn't work

Dear all,

 

I have a report where I track my orders. I created a calendar table based on my dates in my data and marked it as a date table.

Normally I can calculate YTD as a measure but due to new year's delivery dates my calendar includes dates for 2021 and my formula stop working. Do I miss something or do I have to update my measure?

 

regards

 

my data table and calendar table relation is based on "Delivery Date" 

 

 

Date = VAR MinYear = Year (MIN('Fullfilment Report'[Created On]))
VAR MaxYear = Year (MAX('Fullfilment Report'[Delivery date]))
RETURN 
ADDCOLUMNS( FILTER ( CALENDARAUTO() , AND ( YEAR( [Date]) >= MinYear , YEAR ([Date]) <= MaxYear)) , 
"Year" , YEAR([Date]), 
"Month", MONTH([Date]),
"Month Name" , FORMAT([Date], "MMM"),
"Week Nr" , WEEKNUM([Date],2),
"Year Month" , FORMAT([Date], "YYYY.MM") )

 

 

 

my YTD measure

 

 

YTD =
CALCULATE ( [New Fulfillment Rate2], DATESYTD ( 'Date'[Date] ) )

 

 

 

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

What context and visuals are you using this in?

 

You can either

OPTION A: update your formula to use manual reference to TODAY(), such as: 

YTD =
CALCULATE ( [New Fulfillment Rate2], YEAR(FactTable[Date]) = YEAR(TODAY()))

 

or, OPTION B: add a year context to your report by putting a date filter on the page that has 2020 as the max year. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

4 REPLIES 4
v-janeyg-msft
Community Support
Community Support

Hi, @jamuka 

 

It’s my pleasure to answer for you.

According to your description, It's not vey clear where problems occur, but you can try to do it without time intelligence function.

Like this:

YTD =
VAR d =
    MAX ( 'Date'[Date] )
RETURN
    CALCULATE (
        [New Fulfillment Rate2],
        FILTER (
            ALL ( 'Fullfilment Report' ),
            YEAR ( [Delivery Date] ) = YEAR ( d )
                && [Delivery Date] <= d
        )
    )

If it doesn’t solve your problem, please add more information and feel free to ask me.

 

Best Regards

Janey Guo

 

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

Hello Janey, 

 

sorry for late reply. thanks to Allison I solved my problem.

My calendar table has date entries for 2021 (due to delivery dates) and I calculated YTD based on delivery date therefore my YTD measure returns blank values. I add year filter to my measure (which will show current year) and it works.

With your fomula it shows same value for every entry in my matrix table.

 

regards

AllisonKennedy
Super User
Super User

What context and visuals are you using this in?

 

You can either

OPTION A: update your formula to use manual reference to TODAY(), such as: 

YTD =
CALCULATE ( [New Fulfillment Rate2], YEAR(FactTable[Date]) = YEAR(TODAY()))

 

or, OPTION B: add a year context to your report by putting a date filter on the page that has 2020 as the max year. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hello Allison,

 

sorry for late reply. thank you for your help. both of your options worked.

 

have nice week.

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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