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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
jbeets
Frequent Visitor

Return value for prior year based on selected date range

Hello, This measure returns the number of items in the table based on the date range selected and is working as expected. I would like to create another that looks at the same timeframe but returns the value for the prior year.  The point is to create two measures that allow for a comparison of the two numbers for the same timeframe for each year. 
In this example I have the date range 1/1/2023 - 3/31/2023 selected. I am trying to modify the measure to return the number of items for 1/1/2022 - 3/31/2022.

* Test 4 = 
var datestart = 
    CALCULATE(MIN('Claim Reported Date'[Calendar Date]),ALLSELECTED('Claim Reported Date'[Calendar Date]))
var dateend = CALCULATE(MAX('Claim Reported Date'[Calendar Date]),ALLSELECTED('Claim Reported Date'[Calendar Date]))
var catcount = 
CALCULATE(
    COUNTROWS('Claim Catastrophe'),
    ('Claim Catastrophe'[CAT Valid From Dt])>=datestart,
    ('Claim Catastrophe'[CAT Valid From Dt])<=dateend
)
Return catcount

 I appreciate any help you can provide. Thanks!

1 ACCEPTED SOLUTION
Alf94
Solution Supplier
Solution Supplier

Hi @jbeets ,

 

I think the following may do the trick:

 

Test 4 Last Year = 
  CALCULATE(
    [* Test 4]
    SAMEPERIODLASTYEAR( 'Claim Reported Date'[Calendar Date] )
  )

 

It should return the value of the measure you presented but on previous year.

 

If I answered your question, please mark my post as a solution.

 

Best,

View solution in original post

2 REPLIES 2
jbeets
Frequent Visitor

Thank you so much! This is exactly what I needed.

Alf94
Solution Supplier
Solution Supplier

Hi @jbeets ,

 

I think the following may do the trick:

 

Test 4 Last Year = 
  CALCULATE(
    [* Test 4]
    SAMEPERIODLASTYEAR( 'Claim Reported Date'[Calendar Date] )
  )

 

It should return the value of the measure you presented but on previous year.

 

If I answered your question, please mark my post as a solution.

 

Best,

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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