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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Super User
Super User

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.