Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Fcoatis
Post Patron
Post 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

 

1 ACCEPTED SOLUTION

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 

View solution in original post

4 REPLIES 4
v-huizhn-msft
Employee
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

@v-huizhn-msft

 

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

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 

Hi @Fcoatis,

Congratulations, you have resolved your issue by yourself. Please mark your workaround as answer, so more people will benefit from here.

Best Regards,
Angelia

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.