Forum Discussion
aamoody81
8 years agoRegular Visitor
SAMEPERIODLASTYEAR for only values in current year
Hi, I'm trying to show the value from prior year for products. I only want the products that are present in the current year to show. What I would like: Product SamePeriodSalesLastYear
...
- 8 years ago
Hi,
Try this
=IF([Sum of ProductSales]=0,BLANK(),CALCULATE([Sum of ProductSales], SAMEPERIODLASTYEAR(D_DATE[DATE])))
Hope this helps.
AlbertoFerrari
Most Valuable Professional
8 years agoThis (or something similar, of course) should work:
=
CALCULATE (
SUM ( Sales[Amount] ),
SAMEPERIODLASTYEAR ( Date[Date] ),
VALUES ( Sales[ProductKey] )
)Basically, you move hte filter on the date, but you consolidate the filter over the products based on the current product keys.
Have fun with DAX!
Alberto Ferrari
http://www.sqlbi.com
- aamoody818 years agoRegular Visitor
I think this was really close.
= CALCULATE ( SUM ( Sales[Amount] ), SAMEPERIODLASTYEAR ( Date[Date] ),
Sales[ProductKey] IN VALUES ( Sales[ProductKey] ) )I found this below. Unfortunatley for me the IN function isnt avaiable in my version.
https://stackoverflow.com/questions/48301281/calculate-previous-year-based-on-this-year-condition
Thank you for your respose.