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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
FrancisSaman
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
amitchandak
Super User
Super User

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

sturlaws
Resident Rockstar
Resident Rockstar

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. 

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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