Forum Discussion

heatherkw's avatar
heatherkw
Icon for Helper I rankHelper I
4 years ago
Solved

Determine Active Clients At Any Point in Time

Hello,

 

I'm pretty new to Power BI and DAX, and am trying to wrap my brain around how to do something. We have clients that come in and out of our system and need a way to determine if they are active on certain dates or within certain timeframes. For example, a user selects May 1, 2022 and we want to show how many active clients we had on that date. We have enrollment dates and exit dates, but not all clients have exit dates as they are still active, so we have to account for that too. We would also want to be able to do this for entire months and years too, to show how many unique active clients we had during these larger time frames too. I know how to "hardcode" this to a specific date, but just don't know how to make it happen with dynamic date selection. Any help or suggestions would be appreciated. 🙂

  • Thanks! It took me a while and quite a lot of tries and versions, but I made it work!

  • Sure! I use this calculation all of the time now. It usually looks something like this:

    ActiveClients =
    VAR MinDate = FIRSTDATE('Date'[Date])
    VAR MaxDate = LASTDATE('Date'[Date])
    RETURN
    CALCULATE (
    DISTINCTCOUNT('CombinedTables'[PersonalID]),
    'CombinedTables'[EnrollmentEnd]> MinDate,
    'CombinedTables'[EnrollmentStart] <= MaxDate)

10 Replies

  • heatherkw there are lot of blogs/videos about this. if you search for employee head count (common scenario) DAX, you will find a solution.

     

    Here is one, I'm not endorsing any solution because I don't know how they will perform. Here is one example link Employee Head Count Over Time | Power BI Exchange (pbiusergroup.com)

     

     

    Follow us on LinkedIn and  to our YouTube channel

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.

     

    • heatherkw's avatar
      heatherkw
      Icon for Helper I rankHelper I

      Thanks! It took me a while and quite a lot of tries and versions, but I made it work!

      • ThomasSan's avatar
        ThomasSan
        Icon for Helper IV rankHelper IV

        Would you please share your solution with the community? After all, this is why this community exists

    • heatherkw's avatar
      heatherkw
      Icon for Helper I rankHelper I
      ClientIDEnrollmentIDEnrollmentStartEnrollmentEnd
      1123471/1/20195/31/2019
      1123495/31/2019 
      21235212/22/20196/1/2020
      3123541/15/2020 
      4123572/24/20205/31/2020
      4123605/31/20209/30/2020
      41236312/30/2020 
      5123584/3/20204/4/2020
      5123594/4/2020 
      6123506/2/201912/31/2019
      61235312/31/20196/1/2020
      7123617/4/2020 
      8123516/2/2019 
      91236212/2/2020 
      10123453/2/20186/4/2018
      10123469/2/20182/3/2019
      10123485/2/201912/2/2019
      10123552/4/20202/5/2020
      10123562/5/2020 

      Here is some made up data. I did look around at some other threads and thought I found a solution, but it didn't account for a person having multiple enrollments over a time period, and only seemed to allow counts on a specific date, rather than also looking at say, annual counts. It's very common for our clients to have multiple enrollments, but we only want distinct counts based on their client ids. 

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Icon for Super User rankSuper User

        Hi,

        How can the enrollment start date be the same as the enrollment end date (see ClientID 1).  If the enrollment ends on 5/31/2019, shouldn't the next one start frp, 1/6/2019?  If my understanding is correct, then please share revised data.