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
Anonymous
Not applicable

Last year YTD

Hi,

    I need to calculate the Last year YTD value. Say if today's date is Feb 24th 2020 i need to compare current year YTD value to last year YTD value i.e till 24th Feb 2019. I used a formula as

YTD= CALCULATE([Enquiry],DATESYTD(Date[Date]))
YTD_LY = CALCULATE(YTD,SAMEPERIODLASTYEAR(Date[Date]))
When i use this query i getting last year value till 28th Febuary 2019 but i need to get only till 24th Feb 2019 since my current date is 24th Feb 2020
Capture.PNG
1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

HI  @Anonymous 

The simple way is that add a IF conditional in the formula

YTD = IF(MAX('Date'[Date])<=TODAY(),CALCULATE([Enquiry],DATESYTD('Date'[Date])))
YTD_LY = IF(MAX('Date'[Date])<=TODAY(),CALCULATE([YTD],SAMEPERIODLASTYEAR('Date'[Date])))

 

Regards,

Lin

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

View solution in original post

3 REPLIES 3
v-lili6-msft
Community Support
Community Support

HI  @Anonymous 

The simple way is that add a IF conditional in the formula

YTD = IF(MAX('Date'[Date])<=TODAY(),CALCULATE([Enquiry],DATESYTD('Date'[Date])))
YTD_LY = IF(MAX('Date'[Date])<=TODAY(),CALCULATE([YTD],SAMEPERIODLASTYEAR('Date'[Date])))

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

Giving Date can make YTD work best.

Other You can try

YTD= CALCULATE([Enquiry],DATESYTD(Date[Date]), Date[Date]<=today())
YTD_LY = CALCULATE(YTD, dateadd(Date[Date],1,Year)<=today())

 

Or you can put a visual level filter by drag the date from calendar and date in last 2 year including today

vivran22
Community Champion
Community Champion

Hello @Anonymous 

 

I believe, it has to do with the slicers you have applied on the report. 

 

I have recreated a  sample visual for this:

 

Below I have used the slicers on Year & Month:

 

Filter MOnth.PNG

 

and below I have used date as slicer:

 

Filter Date.PNG

 

When you are selecting Feb 2012 in the slicer, it is picking all the dates within Feb. 

 

Cheers!
Vivek


If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂


https://www.vivran.in/

Connect on LinkedIn

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.