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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

YTD Closed month (prior month) and when it is January it refers to December of prior year

Hello,

 

I've been using the datesytd() and sameperiodlastyear() to get YTD to analyze the YTD spend.  I refresh the data after the period closes.  Normally if I do this quick enough there are no postings for the current month so it isn't a problem.

 

However - if I'm ever late then there are postings in the current month that I don't want because the period isn't closed AND now that is is January and I want to show YTD December, I'm getting 0's because there is no YTD January 2020 data.

 

How would you fix this?  Its not as simple as subtracting a month.  Maybe some sort of days(today()) function to subtract from the date?

3 REPLIES 3
amitchandak
Super User
Super User

Try to restrict it by max available date

YTD Sales = 
var _max = maxx(Sales,Sales[Date])

CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date]),'Date'[Date]<_max)
//OR
//CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date]),Sales[Date]<_max)

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 -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

Add Year and month slicers to the report page.  Then the formulas will know what month is current. 

kentyler
Solution Sage
Solution Sage

You could substitute using DATESBETWEEN() for DATESYTD, they both return a column of dates, but datesbetween would allow you to customize the date range.





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors