Forum Discussion
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 catcountI appreciate any help you can provide. Thanks!
Hi Anonymous ,
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,
2 Replies
- Alf94Solution Supplier
Hi Anonymous ,
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,
- AnonymousNot applicable
Thank you so much! This is exactly what I needed.