cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PDRTXRA
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.

 

Thanks in advance.

Sales (Today-1)DONE
Monthly SalesDONE
Monthly Sales Last YearUNDONE
Sales from October 1st to (Today -1)DONE
Sales from October 1st Last year to (Today -1) Last yearUNDONE
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @PDRTXRA ,

I created some data:

vyangliumsft_0-1656051949634.png

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:

vyangliumsft_1-1656051949638.png

 

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

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @PDRTXRA ,

I created some data:

vyangliumsft_0-1656051949634.png

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:

vyangliumsft_1-1656051949638.png

 

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

SpartaBI
Community Champion
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]
)

Please read this article to see you have everyhing in place:
https://www.daxpatterns.com/standard-time-related-calculations/


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors