Forum Discussion

apmulhearn's avatar
apmulhearn
Helper III
5 years ago
Solved

Need Help Identifying Repeat Clients Over Dynamic Time Period

Hello,

 

I am trying to calculate the percentage of new bookers vs repeat bookers.

Our variable driving date is the "First Payment Date."  So I need the calculation to adjust as the First Payment Date Range changes.

 

The way we know a guest has travelled before is based on their End Date.

 

The question I want to answer is, for All First Payments Received between X/XX/XXXX - X/XX/XXXX, how many clients had already completed AT LEAST one trip?

 

Using this small sample, if the First Payment Date Range were 9/1/2017 - 9/1/2019, only the rows in blue would be eligible, and my answer would be 1. Client ID 98076 MADE a booking in my queried range and completed 2 already.  

 

So I guess I need a DISTINCTCOUNT of Client IDs which, over a given FIRST PAYMENT DATE range, have End Dates in other rows which are PRIOR TO the dates in the FIRST PAYMENT DATE range.



ClientIDEnd DateTrip CodeStatusFirst Payment Date
123451/1/2017XA908Completed3/17/2016
123452/18/2021BA807Completed7/1/2020
123455/11/2023XA908Booked6/1/2021
123454/1/2015SA306Completed3/1/2014
980766/10/2018FA432Completed9/23/2017
980764/3/2019BA999Completed7/17/2018
980764/3/2020BA346Completed6/7/2019
43562/20/2020SA456Completed8/3/2019
  • Hi, apmulhearn 

     

    First create a calendar table

    Calendar = 
    var _min=MIN('Table'[First Payment Date])
    var _max=MAX('Table'[First Payment Date])
    return
    CALENDAR(_min,_max)

    then create two measures.

    _isResult = 
    var _payInRange=MAX('Table'[First Payment Date])in DATESBETWEEN('Calendar'[Date],MIN('Calendar'[Date]),MAX('Calendar'[Date]))
    var _endInRange=MAX('Table'[End Date])in DATESBETWEEN('Calendar'[Date],MIN('Calendar'[Date]),MAX('Calendar'[Date]))
    var _if=IF(_payInRange&&_endInRange,1,0)
    return
        _if
    _distinctcountID = 
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[ClientID] ),
        FILTER ( ALL ( 'Table' ), [_isResult] = 1 )
    )

    so we can show it with a card visual.

    Result:

    Please refer to the attachment below for details

     

     

    Hope this helps.

     

    Best Regards,
    Community Support Team _ Zeon Zheng
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

1 Reply

  • Hi, apmulhearn 

     

    First create a calendar table

    Calendar = 
    var _min=MIN('Table'[First Payment Date])
    var _max=MAX('Table'[First Payment Date])
    return
    CALENDAR(_min,_max)

    then create two measures.

    _isResult = 
    var _payInRange=MAX('Table'[First Payment Date])in DATESBETWEEN('Calendar'[Date],MIN('Calendar'[Date]),MAX('Calendar'[Date]))
    var _endInRange=MAX('Table'[End Date])in DATESBETWEEN('Calendar'[Date],MIN('Calendar'[Date]),MAX('Calendar'[Date]))
    var _if=IF(_payInRange&&_endInRange,1,0)
    return
        _if
    _distinctcountID = 
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[ClientID] ),
        FILTER ( ALL ( 'Table' ), [_isResult] = 1 )
    )

    so we can show it with a card visual.

    Result:

    Please refer to the attachment below for details

     

     

    Hope this helps.

     

    Best Regards,
    Community Support Team _ Zeon Zheng
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.