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
sachinnamdeo798
Frequent Visitor

SAME PERIOD LAST YEAR DATEWISE

DEAR COMMUNITY,
"I want to calculate exact sameperoid last year sales value  it means if today is 24 apr 23 then the measure should return only 24 days data of apr from 2022 not whole month but the measure i usre this return me the right value but it returns for whole month".

Privious Year mtd sales = CALCULATE([MTD],SAMEPERIODLASTYEAR('Calendar_new'[Date]))

Here mtd is month to date sale of our product

MTD = TOTALMTD(SUM(CUBE_INVOICE[INVOICE QUANTITY]),'Calendar_new'[Date])

Please help

1 ACCEPTED SOLUTION

Thank you for your valuable solution.
yes i can use dateadd function like this 

previous year  = CALCULATE([MTD],DATEADD(Calendar_new[Date],-365,DAY))

But this measure also have an issue that if previous year was leap year than it give return value of one day before not exact.
As i previously mention if today is 24 apr and previous year was leap year than it rerutn me value till 23 apr.



 

View solution in original post

2 REPLIES 2
ppm1
Solution Sage
Solution Sage

Please try the DATEADD function instead.

DATEADD - DAX Guide

 

Pat

Microsoft Employee

Thank you for your valuable solution.
yes i can use dateadd function like this 

previous year  = CALCULATE([MTD],DATEADD(Calendar_new[Date],-365,DAY))

But this measure also have an issue that if previous year was leap year than it give return value of one day before not exact.
As i previously mention if today is 24 apr and previous year was leap year than it rerutn me value till 23 apr.



 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors