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
kundan_ray
New Member

YTD and PY YTD

Hi Folks,
I have 3 years of data in my dataset, 2022, 2023 complete year and 2024 till today i.e., (05/09/2024). I want to calculate YoY growth. 
When I choose 2024 in slicer, it should show CY till the present day and PY should show the sameperiod sales (sameperiodlastyear won't work because it will consider complete May month when compared to last year) 

When I choose 2023 in slicer, it should show the complete 2023 in CY and 2022 in PY sales.

Please advise the dax. 

Thanks

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

6 REPLIES 6
Ahmedx
Super User
Super User

pls try

 

Ahmedx
Super User
Super User

you need to create this column in the calendar
Screenshot_1.png
and then you can create two measures

Sales YTD = CALCULATE(SUM('Table'[Value]),'Calendar'[YTD]="YTD")

LastYearYTD = CALCULATE([Sales YTD],DATEADD('Calendar'[Date],-1,YEAR))

@Ahmedx , I used your calculation but not able to get desired results. 

Sales YTD should present all values for 2023, and LastYEARYTD should present values less than Oct 1 for 2022, as we have data till Oct 2023. For 2022, LastYearYTD present values till July 2022 not for december 2022.

 

Screenshot_6.png

LYTD 1.pbix

Power BI file attached, please help.

LYTD 1.pbix

 

Best Regards,

Fahad Qadir

pls try

 

@Ahmedx  SalesYTD for 2022 should be blank as I select 2023 and 2022, and LastYear YTD for 2023 should be blanks. 

LastYear YTD for 2022 should presents all values less than Oct 1 2022, as we have 1st Oct 2023 is the max(last) date in 2023. 
is it possible? Thanks alot for your response.

fahadqadir3_0-1715264395445.png

 

Surya9
Resolver III
Resolver III

you can try 
var CY = [measure]
var Py = calculate ([measure],all(date),date(date)>=date(year-1,1,1) && date<=Edate(date ,-12))

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.