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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
LeahS
Frequent Visitor

Active Clients in time frame

I have the below data.  I'm trying to create a measure that will be tied to my date slicer (which filters by month & year).  I want the measure to count how many active clients there were in the month selected based on client start date and end date.  I tried to use a var_date syntax I saw on-line, but since I'm new to power BI, I couldn't make it work with 2 conditions.  Does anyone have any ideas on what might work?  It would also be gre

ClientStart_DateDischarge_date
Le St10/17/2022 
Pe Se7/14/2022 
Ch Pa5/1/20236/1/2023
Zo Gi2/13/20237/2/2023
Be Sp12/21/20223/15/2023
Fa Gi11/20/2022 

at if I could calculate current active clients, but I couldn't get ISBLANK() to work for me.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @LeahS ,

 

I suggest you to create a measure as below to count the active clients.

Count Active Clients =
VAR _SELECTSTART =
    MIN ( 'Date'[Date] )
VAR _SELECTEND =
    MAX ( 'Date'[Date] )
RETURN
    COUNTX (
        FILTER (
            'Lincoln Client Info',
            'Lincoln Client Info'[Start Date] <= _SELECTEND
                && OR (
                    'Lincoln Client Info'[Discharge Date] >= _SELECTSTART,
                    'Lincoln Client Info'[Discharge Date] = BLANK ()
                )
        ),
        [Client]
    )

Result is as below.

vrzhoumsft_0-1692257670754.png

vrzhoumsft_1-1692257829065.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
LeahS
Frequent Visitor

Thanks!  That worked.  And the syntax is easy enough to understand that I can adapt it for other measures.

Ashish_Mathur
Super User
Super User

Hi,

Please find attached the PBI file.

Hope this helps.

Ashish_Mathur_0-1691462819841.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Community Champion
Community Champion

@LeahS 
Take a look at these two Quick Measures as I think you want something like them.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 

The first one works mostly, but I can't get the count right.  I think my column names are off.  Below is the measure I created.  Can you tell me where I went wrong?

Active Clients L = VAR tmpclients = ADDCOLUMNS('Lincoln Client Info',"Active",IF(ISBLANK([Discharge Date]),TODAY(),[Discharge Date]))
VAR tmpTable =  
SELECTCOLUMNS(
    FILTER(
        GENERATE(
            tmpclients,
            'Date Table'
        ),
        [Date] >= [Start Date] &&
        [Date] <= [Discharge Date]
    ),
    "Active",[Start Date],
    "Date",[Date]
)
VAR tmpTable1 = GROUPBY(tmpTable,[Active],"Count",COUNTX(CURRENTGROUP(),[Date]))
RETURN COUNTROWS(tmpTable1)
Anonymous
Not applicable

Hi @LeahS ,

 

I suggest you to create a measure as below to count the active clients.

Count Active Clients =
VAR _SELECTSTART =
    MIN ( 'Date'[Date] )
VAR _SELECTEND =
    MAX ( 'Date'[Date] )
RETURN
    COUNTX (
        FILTER (
            'Lincoln Client Info',
            'Lincoln Client Info'[Start Date] <= _SELECTEND
                && OR (
                    'Lincoln Client Info'[Discharge Date] >= _SELECTSTART,
                    'Lincoln Client Info'[Discharge Date] = BLANK ()
                )
        ),
        [Client]
    )

Result is as below.

vrzhoumsft_0-1692257670754.png

vrzhoumsft_1-1692257829065.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.