Forum Discussion
Filtering for data 2 weeks prior the current date
- 4 years ago
Hi Anonymous ,
First you need two separate tables, a date table and a fact table. They are not related to each other.
Then create a measure, like the following.
Measure = VAR _selected = MAX ( Slicer[Date] ) VAR _start = _selected - 14 RETURN IF ( SELECTEDVALUE ( 'Table'[Date] ) >= _start && SELECTEDVALUE ( 'Table'[Date] ) <= _selected, 1 )Then put the measure in filter pane and set it show items which is 1.
The output:
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
14_days_ago =
VAR __LAST_DATE = LASTDATE(DateTable[Date])
VAR __FIRST_DATE = FIRSTDATE(DateTable[Date])
return
AVERAGEX(
DATESBETWEEN(
DateTable[Date],
DATEADD(__FIRST_DATE, -14, DAY),
DATEADD(__LAST_DATE, -14, DAY)
),
CALCULATE([WHATEVER YOU WANT TO CALCULATE])
)What does the CALCULATE at the end of the DAX expression do exactly? Can you giva an example of something to "plug in" there please?
Thank you
- vapid1284 years ago
Solution Specialist
If you have a measure: lines = countrows(table)
in the function, that would be "calculate[lines]" <-- measure name
One more thing, the function is for daily average, if you want daily sum, change AVERAGEX to SUMX.