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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
SCTomas92
Regular Visitor

Number of users active in a selected date (with start date and end date)

Hi all, 

I require assistance with some Power BI measures. I'm trying to determine the number of active employees within a selected timeframe based on the "Date" (contract start date) and "EndDate" (contract end date) fields. Blank values in the "Date" field indicate that the employee was already active when data collection began, while empty values in the "EndDate" field signify that the employee is presently active. Whenever an employee gets promoted, their record is updated with an "EndDate" value, and a new entry is created.

 

The objective is to allow the end user to select two separate periods using slicers and view a detailed table showing which employees are new or no longer employed by the company. To facilitate this, I have duplicated the calendar table.

The measures I have created are as follows:

  1. Employees_FirstMonthSelected: This measure calculates the count of active employees in the first selected month.
    Employees_FirstMonthSelected =
    CALCULATE( COUNTROWS(WorkDayGlobal) + 0,
        AND(
        OR(ISBLANK(WorkDayGlobal[Date]), WorkDayGlobal[Date] <= MAX(Calendar[Date])),
        OR(ISBLANK(WorkDayGlobal[EndDate]), WorkDayGlobal[EndDate] > MAX(Calendar[Date])))
     
  2. Employees_SecondMonthSelected: This measure calculates the count of active employees in the second selected month.
    Employees_SecondMonthSelected =
    VAR Max_Date =
    MAX('Calendar2'[Date])
    RETURN
    CALCULATE( COUNTROWS(WorkDayGlobal) + 0,
        WorkDayGlobal[Date] <= Max_Date || ISBLANK(WorkDayGlobal[Date]),
        WorkDayGlobal[EndDate] > Max_Date || ISBLANK(WorkDayGlobal[EndDate]))

The issue I'm facing is that when I generate a detailed table of employees, some of them do not appear as active in periods when they were actually active (verified in the WorkdayGlobal table). For instance, if the user selects January 2023 and May 2023, an employee who worked from September 13, 2022, to April 11, 2023, and had a contract change with a start date of April 11 without an end date, should be considered active in both January 2023 and May 2023. However, they only appear as active in January.

I would greatly appreciate any insights on why this might be happening.

Thank you for your assistance.

1 REPLY 1
johnt75
Super User
Super User

Do you have any relationships between either of the calendar tables and the WorkDayGlobal table ?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.