Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

SAMEPERIODLASTYEAR returning no data

I have a table with claim and serDate.

I have binned/grouped serDate into  a  7 day group.

 

Using 

Total Claims Last Month = CALCULATE(CALCULATE([Total Claims], SAMEPERIODLASTYEAR('log'[SerDate (bins) 2])), FILTER('log','log'[SerDate (bins) 2] < TODAY()))
 
returns no data 
 
Total Claims Last Year = CALCULATE(CALCULATE([Total Claims by Receive Date], SAMEPERIODLASTYEAR('log'[SerDate])), FILTER('log','log'[SerDate] < TODAY()))
 
Also returns  no data 
 
Total Claims = COUNTA('log'[Claim]) 
returns the correct count.

Total Claims by Receive Date = CALCULATE(CALCULATE(
COUNT('log'[Claim]), FILTER('log','log'[SerDate] < TODAY())))
 
How can I create a table that compares this year vs last? Count of Claim, Total Claims and Total Claims by recieve data all return valid data. 


  • Anonymous's avatar
    Anonymous
    5 years ago

    Anonymous 
    Because you used today() as the condition, and there is no today's date in the previous year. 

    Just replace the SAMEPERIODLASTYEAR('log'[SerDate]))  to 

    FILTER('log',[SerDate].[Year]=YEAR(TODAY())-1&&[SerDate].[MonthNo]=MONTH(TODAY()) && [SerDate].[Day]=DAY(TODAY()))
     
     
    Paul Zheng _ Community Support Team
    If this post helps, please Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Anonymous , with time intelligence you should use a date table as it requires continous dates. Date tbale should have all date for last year in data tbale

     

     

    examples, I also doubt the need to <today ()

    Year behind Sales = CALCULATE([Total Claims],SAMEPERIODLASTYEAR('Date'[Date]))
    Year behind Sales = CALCULATE([Total Claims]),dateadd('Date'[Date],-1,Year))

     

    or

    forced=
    var _max = date(year(today()),month(today())-3,day(today()))
    return

    CALCULATE([Total Claims]),dateadd('Date'[Date],-1,Year),,'Date'[Date]<=_max)

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous 
    Because you used today() as the condition, and there is no today's date in the previous year. 

    Just replace the SAMEPERIODLASTYEAR('log'[SerDate]))  to 

    FILTER('log',[SerDate].[Year]=YEAR(TODAY())-1&&[SerDate].[MonthNo]=MONTH(TODAY()) && [SerDate].[Day]=DAY(TODAY()))
     
     
    Paul Zheng _ Community Support Team
    If this post helps, please Accept it as the solution to help the other members find it more quickly.