cancel
Showing results for
Did you mean:
Frequent Visitor

## Measure for sums in different years

Hi. Basically, I need the sales amount for the same period but last year. I'm putting this vales in cards so I failed to use the SAMEPERIODLASTYEAR function. I need to get a measure.

 Sales (Today-1) DONE Monthly Sales DONE Monthly Sales Last Year UNDONE Sales from October 1st to (Today -1) DONE Sales from October 1st Last year to (Today -1) Last year UNDONE
1 ACCEPTED SOLUTION
Community Support

Hi  @PDRTXRA ,

I created some data:

Here are the steps you can follow：

1. Create measure.

``````Sales (Today-1) =
CALCULATE(SUM('Table'[rand]),FILTER(ALL('Table'),'Table'[Date]=TODAY()-1)
)``````
``````Monthly Sales =
CALCULATE(SUM('Table'[rand]),FILTER(ALL('Table'),'Table'[Date]>= DATE(YEAR(TODAY()),MONTH(TODAY())-1,1) &&'Table'[Date]<=EOMONTH(TODAY(),-1)))``````
``````Monthly Sales Last Year =
CALCULATE(SUM('Table'[rand]),FILTER(ALL('Table'),'Table'[Date]>= DATE(YEAR(TODAY())-1,MONTH(TODAY())-1,1)&&'Table'[Date]<=EOMONTH(TODAY(),-13)))``````
``````Sales from October 1st to (Today -1) =
CALCULATE(SUM('Table'[rand]),FILTER(ALL('Table'),'Table'[Date]>=TODAY()-1&&'Table'[Date]<=DATE(YEAR(TODAY()),10,1)))``````
``````Sales from October 1st Last year to (Today -1) Last year =
CALCULATE(SUM('Table'[rand]),FILTER(ALL('Table'),'Table'[Date]>=DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY()))&&'Table'[Date]<=DATE(YEAR(TODAY())-1,10,1)))``````

2. Result:

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

2 REPLIES 2
Community Support

Hi  @PDRTXRA ,

I created some data:

Here are the steps you can follow：

1. Create measure.

``````Sales (Today-1) =
CALCULATE(SUM('Table'[rand]),FILTER(ALL('Table'),'Table'[Date]=TODAY()-1)
)``````
``````Monthly Sales =
CALCULATE(SUM('Table'[rand]),FILTER(ALL('Table'),'Table'[Date]>= DATE(YEAR(TODAY()),MONTH(TODAY())-1,1) &&'Table'[Date]<=EOMONTH(TODAY(),-1)))``````
``````Monthly Sales Last Year =
CALCULATE(SUM('Table'[rand]),FILTER(ALL('Table'),'Table'[Date]>= DATE(YEAR(TODAY())-1,MONTH(TODAY())-1,1)&&'Table'[Date]<=EOMONTH(TODAY(),-13)))``````
``````Sales from October 1st to (Today -1) =
CALCULATE(SUM('Table'[rand]),FILTER(ALL('Table'),'Table'[Date]>=TODAY()-1&&'Table'[Date]<=DATE(YEAR(TODAY()),10,1)))``````
``````Sales from October 1st Last year to (Today -1) Last year =
CALCULATE(SUM('Table'[rand]),FILTER(ALL('Table'),'Table'[Date]>=DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY()))&&'Table'[Date]<=DATE(YEAR(TODAY())-1,10,1)))``````

2. Result:

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Community Champion

@PDRTXRA in case you have a proper date table (or just the autodate time table) then this measure should work:
Monthly Sales Last Year
CALCULATE(
[Monthly Sales],
SAMEPERIODLASTYEAR('Date'[Date]
)

https://www.daxpatterns.com/standard-time-related-calculations/

Announcements