Forum Discussion
Fcoatis
9 years agoPost Patron
Next two weeks visits
In a simple table I have Dates in one column and Names in the second one. I need to calculate number of visits in the next 2 weeks from the max date in the filter context. Any help?
Thanks in advance
This seems to resolve:
Next2Wks = var max_Date = CALCULATE(MAX('Calendar'[Date]);ALLSELECTED('Calendar'[Date])) RETURN CALCULATE(COUNTA(tVisitas[Nome]);FILTER(all('Calendar');'Calendar'[Date]>=max_Date&&'Calendar'[Date]<=max_Date+16))Thank you
4 Replies
- v-huizhn-msftMicrosoft Employee
Hi Fcoatis,
The filter context is a slicer, right? If it is, you need to create a measure to get the max date of the slicer. Please use the formula below.max_date=CALCULATED(MAX(filtertable[date]),ALLSELECTED(filtertable[date]))
Then create a measure using the formula.the number of visits=CALCULATE(COUNTA(Table[name]),FILTER(Table,Table[Date]>=[max_date]&&Table[Date]<=DATEADD([max_date],14,day))
Best Regards,
Angelia- FcoatisPost Patron
Thank you for the help,
But the expression <=DATEADD([max_date],14,day) wasnt accepetd.
Heres my pbix example https://www.dropbox.com/s/er7vviseqjbsv46/visitas.pbix?dl=0
Fabio
- FcoatisPost Patron
This seems to resolve:
Next2Wks = var max_Date = CALCULATE(MAX('Calendar'[Date]);ALLSELECTED('Calendar'[Date])) RETURN CALCULATE(COUNTA(tVisitas[Nome]);FILTER(all('Calendar');'Calendar'[Date]>=max_Date&&'Calendar'[Date]<=max_Date+16))Thank you