Forum Discussion
auxilio99357
5 years agoFrequent Visitor
SAMEPERIODLASTYEAR()
Hello!!! I´m building a sales report and have a problem with time intelligence mesures. on the report i have two data tables, the first one is a sales table with the following columns: client/d...
- 5 years ago
Hi auxilio99357 ,
The previous code I supplied for DAX and Power Query M were both intended to be new columns in your calendar table, not measures.
For your specific scenario i.e. sales only go up to two months ago, I would recommend adding a relative month column into your calendar table, something like this:
DAX
_relativeMonth = (YEAR(DimDates[Date]) * 12 + MONTH(DimDates[Date])) - (YEAR(TODAY()) * 12 + MONTH(TODAY()))PQ M
(Date.Year([Date]) * 12 + Date.Month([Date])) - (Date.Year(DateTime.LocalNow()) * 12 + Date.Month(DateTime.LocalNow()))The usage of this in a measure would look something like this:
LYTD = CALCULATE( SUM(Sales[U_Liq]), SAMEPERIODLASTYEAR(DimDates[Date]), DimDates[relativeMonth] <= -2 )Pete
vanessafvg
Community Champion
5 years agohow are you displaying your data? have you got it at the correct grain, can you share a screenshot?
auxilio99357
5 years agoFrequent Visitor