Forum Discussion
Calculate Returning Visits Based on a Dynamic Date Range
Hi LindseyJ ,
Sorry for making the questions but I just want to understand the way you need the calculations.
Let's pickup customers A to D. I can see that the sum of visits by month are 91 (total) for this 4 customers and in april the total is 62 for past 12 months I have for those customers the following count of visits:
I have made changes to the measures:
ReturningCount =
VAR temp_table =
SUMMARIZE (
Visits,
Visits[CLIENT_ID],
"@Visits_Total", SUM ( Visits[#_OF_VISITS] ) - 1
)
RETURN
CALCULATE (
COUNTROWS ( FILTER ( temp_table, [@Visits_Total] > 0 ) ),
DATESINPERIOD(Dates[DATE], MAX(Dates[DATE]), -12, MONTH)
)
Count =
CALCULATE (
SUM ( Visits[#_OF_VISITS] ),
DATESINPERIOD ( Dates[DATE] , MAX ( Dates[DATE] ), -12 , MONTH )
)
Based on the values for the 4 customer can you please tell me what is the result is correct?
I have also made the date table connected with the visits table.
Can you check the result for those 4 customers and tell me if returnin and count is correct?
The dinamic part will be done by making the change of the -12 to a what if parameter but it's a simple change let's first align the number for this fix 12 months from selected date.
Check PBIX file attach.
Hi MFelix, If the data is filtered to ABCD and April 2020 is the selected date, this would be the desired result (58 return visits and 3 returning clients):
If the date range was fixed, I would add 2 columns to the Visits table:
1) One column to rank the dates for each client id:
Visits[DATE], , ASC )
Visits[#_OF_VISITS] - 1,
Visits[#_OF_VISITS] )