cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

YTD ignoring today's date?

Hi everyone

 

I'm trying to get an Absence count together for year to date.

One would assume that the following function would return the desired result: Absences YTD = TOTALYTD(COUNT(Absences[EmployeeId]), Absences[Date])

 

This does however totally seem to ingore today's date...
If, for testing purposes, I add an absence with date > TODAY in my dataset, it is being included as well.
This is very unlogical. Can someone please explain why I'm getting this behavior?

 

Thanks!

 

 

1 ACCEPTED SOLUTION

try this measure

ytd prev year =
CALCULATE (
    TOTALYTD ( SUM ( 'Table'[Sales] ); SAMEPERIODLASTYEAR ( vDate[Date] ) );
    FILTER ( vDate; vDate[Date] <= TODAY () )
)

 

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too. 

View solution in original post

5 REPLIES 5
Super User IV
Super User IV

one option is to try is countx

 

COUNTX(filter(Absences,Absences[date]<today())Absences[EmployeeId])

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Super User II
Super User II

Hi @FrancisSaman ,

 

I am not able to reproduce your issue, could you share your report? Or, if it contains information you cannot share, create a relevant sample report and share it?

 

Cheers,
Sturla

@sturlaws thanks a lot for taking the time to reply!

After having searched hours and hours yesterday, I'm noticing it now working correctly. Without having changed anything...

This is not the first time that I'm noticing very stuborn behavior from PowerBI desktop when working from a duplicated file...

 

Anyways, it seems to work now so that brings me to my next question: I'd like to apply the YTD also to SAMEPERIODLASTYEAR, as my client wants to compare total absences for the running year with the total absences the same period last year. 

I've composed this statement, 

Total absences YTD last year = CALCULATE([Total absences], SAMEPERIODLASTYEAR(Dates[Date]))
but this will of course calculate the SAMEPERIODLASTYEAR for all dates, while I want it to happen limited to all dates up to TODAY (i.e. YTD).
 
Any advice on this would help me a great deal!!
 
Thanks

try this measure

ytd prev year =
CALCULATE (
    TOTALYTD ( SUM ( 'Table'[Sales] ); SAMEPERIODLASTYEAR ( vDate[Date] ) );
    FILTER ( vDate; vDate[Date] <= TODAY () )
)

 

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too. 

View solution in original post

That seems to do the trick @sturlaws  THANKS!

 

Regarding that ignoring of todays date in the YTD function: it does indeed ignore today. I added the marked section and that works now as well...

Total absences YTD = TOTALYTD(COUNT(Absences[Employee id]), Absences[Start date], Dates[Date] <= TODAY())
 
Not what you'd expect from a YTD function imho... YTD is untill today and no further. Last date in the list "as stated in the docs" is very very confusing...

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors