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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
NG1407
Helper I
Helper I

Count ID that has startdate on or before 10th of each month and enddate is after 10th of that month

I need to find the count of only those ID that has startdate <= 10 and enddate > 10 for each month . In other words need to find count of ID that are active till current selected month. A record is active if its enddate is greater than 10th of that month.

For example for jan month I need to count all those ID that has startdate less than or equal to 10thjan and startdate should contain dates from previous month as well that has end date > 10thjan or in future).

 below is the sample data : 

StartdateenddateID
2024-01-102024-12-01a123
2023-12-112024-01-11b123
2024-01-022024-11-08c123
2024-02-112024-02-28d123
2024-03-032024-03-10e123
2024-03-032024-03-15f123

According to above data for jan month the count should be 3, for feb month count should be 0,for march its 1.

I need to display data in line graph. The issue is its filtering the data and showing only jan month data not december month.

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can use

Num active =
VAR CurrentMonth =
    MAX ( 'Date'[Date] )
VAR CutOffDate =
    DATE ( YEAR ( CurrentMonth ), MONTH ( CurrentMonth ), 10 )
VAR Result =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[ID] ),
        'Table'[Start date] <= CutOffDate,
        'Table'[End date] > CutOffDate
            || ISBLANK ( 'Table'[End date] ),
        REMOVEFILTERS ( 'Date' )
    )
RETURN
    Result

If you know that there is only 1 row per ID then you could use COUNTROWS('Table') instead of DISTINCTCOUNT which might be faster.

View solution in original post

2 REPLIES 2
NG1407
Helper I
Helper I

Thank you 🙂 @johnt75 

johnt75
Super User
Super User

You can use

Num active =
VAR CurrentMonth =
    MAX ( 'Date'[Date] )
VAR CutOffDate =
    DATE ( YEAR ( CurrentMonth ), MONTH ( CurrentMonth ), 10 )
VAR Result =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[ID] ),
        'Table'[Start date] <= CutOffDate,
        'Table'[End date] > CutOffDate
            || ISBLANK ( 'Table'[End date] ),
        REMOVEFILTERS ( 'Date' )
    )
RETURN
    Result

If you know that there is only 1 row per ID then you could use COUNTROWS('Table') instead of DISTINCTCOUNT which might be faster.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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