cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jamuka
Helper II
Helper 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 III
Super User III

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. 


Check out my Tokyo 2020 report with live stats - KUDOS much appreciated



Has this post solved your problem? Please mark it as a 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. ?


I work as a trainer and consultant for Microsoft 365, 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 III
Super User III

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. 


Check out my Tokyo 2020 report with live stats - KUDOS much appreciated



Has this post solved your problem? Please mark it as a 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. ?


I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 


www.excelwithallison.com

View solution in original post

Hello Allison,

 

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

 

have nice week.

 

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors