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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
gaor
Frequent Visitor

Same Month Last Year Value not working for Leap year February

Hello,

 

I am calculating the monthly value and the same month last year (it is a measure). I realized that for 2021 Feb, the same month last year (2020 Feb) was not displaying. I tried DATEADD for -12 MONTH and -1 YEAR. I also tried SAMEPERIODLASTYEAR.

 

Is there any way to solve this? 

 

Thank you.

 

Gao

gaor_0-1646364623528.png

 

 

 

 

1 ACCEPTED SOLUTION

Hi Polly,

 

Thank you for the help. I have tried your methods. There are slight differences in requirements though. I would like to display the values by month not by date. 

 

On the left I duplicated your example table value for 2nd day of each month.

 

On the right I simply change the 1st day to end of the month.

gaor_0-1646727993574.png

Neither works expected.

 

With your inspiration, I have found the solution, that is, defining the month number and year number.

 

Corrected Measure = CALCULATE(sum('Table'[value]),FILTER (ALL( 'Table'), ('Table'[date].[Year] = YEAR(MAX ( 'Table'[date] ))-1) && 'Table'[date].[MonthNo]=MONTH(MAX('Table'[date]))))
 
gaor_1-1646729043119.png

 

Thank you.

 

Regards,

gaor

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @gaor ,

Please refer to my pbix file to see if it helps you.

Create a measure and try to use EDATE.

Measure =
VAR previous_ =
    EDATE ( MAX ( 'Table'[date] ), -12 )
RETURN
    CALCULATE (
        MAX ( 'Table'[value] ),
        FILTER ( ALL ( 'Table' ), 'Table'[date] = previous_ )
    )

vpollymsft_0-1646708971041.png

 

If I have misunderstood your meaning, please provide your pbix file without privacy information and desired output.

 

Best Regards

Community Support Team _ Polly

 

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

 

 

 

Hi Polly,

 

Thank you for the help. I have tried your methods. There are slight differences in requirements though. I would like to display the values by month not by date. 

 

On the left I duplicated your example table value for 2nd day of each month.

 

On the right I simply change the 1st day to end of the month.

gaor_0-1646727993574.png

Neither works expected.

 

With your inspiration, I have found the solution, that is, defining the month number and year number.

 

Corrected Measure = CALCULATE(sum('Table'[value]),FILTER (ALL( 'Table'), ('Table'[date].[Year] = YEAR(MAX ( 'Table'[date] ))-1) && 'Table'[date].[MonthNo]=MONTH(MAX('Table'[date]))))
 
gaor_1-1646729043119.png

 

Thank you.

 

Regards,

gaor

 

Tanushree_Kapse
Impactful Individual
Impactful Individual

Hi, @gaor ,

 

You need to pull the complete date Field in the table.
Time Intelligence Function works for whole date.

 

 

Mark this as a solution if I anwered your question. Kudos are always appreciated.

Thanks

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.