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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-rongtiep-msft
Community Support
Community Support

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.

Top Solution Authors