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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PDRTXRA
Helper I
Helper I

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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