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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.