Forum Discussion
Anonymous
9 years agoNot applicable
Reference a previous month using variables in DAX using slicers
Hi I am trying to reference the last week using some dax code that Greg_Deckler provided. I got the last week working but it only works after the firstr week in a given month. How would I ...
vanessafvg
Community Champion
9 years agohave you looked at the previousmonth and sameperiodlastyear etc functions in dax?
https://msdn.microsoft.com/en-us/library/ee634972.aspx
https://msdn.microsoft.com/en-us/library/ee634758.aspx
- Anonymous9 years agoNot applicable
Hi vanessafvg
It is going of week number not months or last year. I understand that when you use these it generates a table and I think it is due to table being constrained the month selected but for this purpose I need to sort of see if it is in the previous month and use that.
- vanessafvg9 years ago
Community Champion
Anonymous you can probably use use datedd with a filter
for example
CALCULATE ( SUM ( 'Table'[Sales Amount] ), FILTER ('Table', 'Table'[Date] ) = DATEADD ( 'Table'[Date], -7, DAY )CALCULATE ( SUM ( 'Table'[Sales Amount] ), FILTER ('Table', 'Table'[Date] ) = DATEADD ( 'Table'[Date], -1, WEEK)haven't test this this though
- Anonymous9 years agoNot applicable
There is no week unfortunalty, only day/month/quarter/year, if we do -7
Something like
internetTargets[weeknum]= WEEKNUM((DATEADD ( 'Calendar$'[Date], -7, DAY ))))
It does not allow you to use dateadd in a filter expression
FILTER ('Table', 'Table'[Date] ) = DATEADD ( 'Table'[Date], -7, DAY )