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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
RexaZii93
Helper I
Helper I

Helpp Please!! how to create YTD for a Selective Year

 

Hi

I need to submit this today and have searched all over the internet but couldn't solve it.

 

I have two datasets one for 2021 to Present and one for 2019 to 2020.

I have created a callender table and connected all datasets to it.

 

Now, I have successfully created a comparison YTD for this year and last year, I want also to add YTD in 2019 which is from Jan 2019 to current month.

 

I also would like it to intract with the filtering, so the filter now show march 2021 as the last month but if I changed it to feb I want the YTD of 2019 calculate to feb also.

 

Much Approciated

6 REPLIES 6
jsaunders_zero9
Responsive Resident
Responsive Resident

Hi @RexaZii93,

If I understand correctly you want to select a date on a slicer and get the YTD value for the selection as well as the YTD for the same period last year.

Selection = May 2020

YTD = Sum of sales from January 2020 through May 2020

YTD Previous  = Sum of sales from January 2019 through May 2019.

Try 

SelectedSales_YTD = CALCULATE(SUM(Sales[Sales]),DATESYTD(_Calendar[Date]))
SelectedSales_PrevYTD = CALCULATE([SelectedSales_YTD],SAMEPERIODLASTYEAR(_Calendar[Date]))

 

jsaunders_zero9_0-1651104839841.png

 

It workd but I had to use a filter for the date in the data itself which has 2020 and 2019 data, can I apply a callender date to filter the data on 2019 with the same formula you wrote?

Great to hear that yu got it sorted @RexaZii93 

Thanks Jsaunders for you response

 

actually I want as the picture you did with the totals, I have the slice set for March but for some reason it shows blanks.

Also my 2019 datasets has two years in it "2020 and 2019", so can specify what year I want in the measure to fixed at 2019?

 

I did your forumal but showing blanks:

Screenshot (53).png

Ashish_Mathur
Super User
Super User

Hi,

Share the download link of your PBI file and also show the expected result there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish

 

the PBI contains some sensetive data but I'll try to do a dummy PBI for you.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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