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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Calculate total count of clients at the end of each month, quarter, and fiscal year

Hi,

 

I am quite new to Power BI and using DAX. How do I go about calculating the total number of client at the end of each month, quarter and fiscal year. The criteria to give a total number of client at the end of each month would require:

 

  • new clients within the month, and
  • client that already existed but still remain active at the clinic, and
  • client exiting within the month

Have include a very small sample data set as an example and the result of it

Client IDStart DateCloseExit Date
10927/11/2019Y3/12/2020
10727/11/2019N 
10827/11/2019Y3/02/2021
1139/01/2020Y11/02/2021
11215/01/2020Y18/07/2020
11115/02/2020N 
11415/03/2020N 
11515/05/2020Y8/10/2020
11716/05/2020Y20/12/2020
11616/08/2020Y20/12/2020
1236/10/2020Y6/12/2020
1226/10/2020N 
1216/12/2020Y28/01/2021
12221/03/2021N 

 

In Power BI should have something like this:

2019
MonthNewExistingExit
Nov3  
Dec 3 

 

2020
MonthNewExistingExit
Jan23 
Feb15 
Mar16 
Apr 7 
May27 
Jun 9 
Jul 91
Aug 9 
Sep 9 
Oct291
Nov 10 
Dec1105

 

2021
MonthNewExistingExit
Jan 61
Feb 51
Mar14 
Apr 5 

 

Any advice or help would be great.

6 REPLIES 6
Anonymous
Not applicable

Hi @tamerj1 

I had a go in using the DAX functions you provided and make the necessary changes to reflect what is on my table of data and columns. However, when I select existing and exit measure no data is shown. It is presented blank

Hi @Anonymous 

please provide details on these changes and advise what are the differences in your model. Do you have relationships with the date table?

Anonymous
Not applicable

Yes I have relationships link to the date table. I have Date with Episode Start Date (aka start date) linked as one to many relationship.

nsiu85_1-1680496200557.png

 

Here is the coding I used from what you have provided and replaced start date with Episode Start Date and exit date with date closed. Not sure what is happening here. 

 

nsiu85_0-1680496137771.png

 

nsiu85_2-1680496287020.png

 

nsiu85_3-1680496558794.png

 

 

@Anonymous 
You can just delete or deactivate he relationship. If for any reason you wish to keep it, you can follow the attached updated sample file

1.png

New = 
CALCULATE ( 
    COUNTROWS ( 'Table' ),
    TREATAS ( VALUES ( 'Date'[Date] ), 'Table'[Start Date] ),
    ALL ( 'Date' )
)
Existing = 
VAR MaxDate = MAX ( 'Date'[Date] )
VAR MinDate = MIN ( 'Date'[Date] )
RETURN
    COUNTROWS ( 
        FILTER ( 
            CALCULATETABLE ( 'Table', ALL ( 'Date' ) ),
            'Table'[Start Date] <= MinDate
                && COALESCE ( 'Table'[Exit Date], TODAY ( ) ) >= MaxDate
        )
    )
Exit = 
IF ( 
    NOT ISEMPTY ( 'Date' ),
    CALCULATE ( 
        COUNTROWS ( 'Table' ),
        TREATAS ( VALUES ( 'Date'[Date] ), 'Table'[Exit Date] ),
        ALL ( 'Date' )
    )
)
Anonymous
Not applicable

Thank you @tamerj1 let me have a play with the big data set I have and see if I get what I need from the report.

tamerj1
Super User
Super User

Hi @Anonymous 
Please refer to attached sample file with the solution

1.png2.png

New = 
CALCULATE ( 
    COUNTROWS ( 'Table' ),
    TREATAS ( VALUES ( 'Date'[Date] ), 'Table'[Start Date] ) 
)
Exit = 
CALCULATE ( 
    COUNTROWS ( 'Table' ),
    TREATAS ( VALUES ( 'Date'[Date] ), 'Table'[Exit Date] ) 
)
Existing = 
VAR MaxDate = MAX ( 'Date'[Date] )
VAR MinDate = MIN ( 'Date'[Date] )
RETURN
    COUNTROWS ( 
        FILTER ( 
            'Table',
            'Table'[Start Date] <= MinDate
                && COALESCE ( 'Table'[Exit Date], TODAY ( ) ) >= MaxDate
        )
    )

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.