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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare 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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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