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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
SPa
Frequent Visitor

Create Card that will show the dates from the previous period last year

Hi all, 

 

Probably dead simple, just can't get it to work. I have the following measure that will display the date range nicely when added to a card. 

 

Measure 1 Result
January 2023 - June 2023
 

Measure 1 Code

Report Period FORMAT = FORMAT(FIRSTDATE('Dates'[Date]), "MMMM YYYY") & " - " & FORMAT(LASTDATE('Dates'[Date]), "MMMM yyyy")
 
What I need is the same, but from the previous year:
 
Measure 2 Desired Result
January 2022 - June 2022
 

Measure 2 Code

?
 
I'm assuming I need to use Sameperiodlastyear, but my attempts have failed
1 ACCEPTED SOLUTION
SPa
Frequent Visitor

Managed to solve it! 

 

Report Period FORMAT last year = 

FORMAT(FIRSTDATE(SAMEPERIODLASTYEAR('Dates'[Date])), "MMMM YYYY") & " - " & FORMAT(LASTDATE(SAMEPERIODLASTYEAR('Dates'[Date])), "MMMM YYYY")

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @SPa ,

I am glad to hear your problem has been resolved, please kindly mark it as the solution. More people will benefit from it.

Thanks for your efforts & time in advance.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

DOLEARY85
Resident Rockstar
Resident Rockstar

Hi,

 

You could try this:

 

Report Period FORMAT last year =
 var _lastyear = YEAR (
        CALCULATE ( MIN ( Dates[Date] ), ALLSELECTED (Dates[Date] ) )-1
    )

    return
FORMAT(FIRSTDATE('Dates'[Date]), "MMMM") & " " & _lastyear & " - " & FORMAT(LASTDATE('Dates'[Date]), "MMMM") & " " & _lastyear
 
DOLEARY85_0-1691004396404.png

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

SPa
Frequent Visitor

Managed to solve it! 

 

Report Period FORMAT last year = 

FORMAT(FIRSTDATE(SAMEPERIODLASTYEAR('Dates'[Date])), "MMMM YYYY") & " - " & FORMAT(LASTDATE(SAMEPERIODLASTYEAR('Dates'[Date])), "MMMM YYYY")

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!