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

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
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.