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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ruanolin
Regular Visitor

Count users between start and end date by month

Hello,
I am performing user counting by company and group.
I have the following tables:

 

Tables.png


With the following tutorial DAX measure with start AND end date for Power BI and with the following DAX formula, I am able to have the user count by company, group and day.

 

 

9 Users currently per groups =
CALCULATE (
    COUNTROWS ( Users ),
    FILTER (
        VALUES ( GroupMembers[startDate] ),
        GroupMembers[startDate] <= MIN ( 'Date'[Dates] )
    ),
    FILTER (
        VALUES ( GroupMembers[endDate] ),
        OR (
            GroupMembers[endDate] = DATE ( 9999, 12, 31 ),
            GroupMembers[endDate] > MAX ( 'Date'[Dates] )
        )
    ),
    FILTER (
        VALUES ( Users[startDate] ),
        Users[startDate] <= MIN ( 'Date'[Dates] )
    ),
    FILTER (
        VALUES ( Users[endDate] ),
        OR (
            Users[endDate] = DATE ( 9999, 12, 31 ),
            Users[endDate] > MAX ( 'Date'[Dates] )
        )
    )
)

 

 

Users per company and group.png

 

The problem is that I want to perform the same count by month instead of days.
When I drill up for the date table, I get the following wrong result:

Users per company and group_drill up.png

 

I would like to obtain the following result (if a user is in the group one day in a month, I want to count it)

 AugustSeptember
E1 - Interns13
E1 - Externs03
E2 - Interns12
E2 - Externs12

 

I attach the sample file

1 REPLY 1
lbendlin
Super User
Super User

some general comments

 

- you may want to spend some time cleaning up your data model

- try not to use auto date time hierarchies

- DO NOT use dates like 9999-12-31  - they are adding an enormous storage overhead and performance impact.  Keep End Dates as BLANK() when they are undefined, and use COALESCE([End Date], TODAY())  to get a meaningful date. 

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.