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
Anonymous
Not applicable

Count number of employees

Hello 

I'm relatively new in PowerBI - DAX
I have one doubt, 
I want to create a measure that show in every "Date" in my Table "Date Time" the number of employees.
To do that I have,
one table with

CodeEntry TimeFiredTimeEnding Contract
00101-01-201002-05-2010 
00201-04-2010 01-09-2012
00301-05-2010  

and a table time with all the dates.
the result I would like is 

DateNumber employes
01-01-20101
...1
01-04-20102
...2
01-05-20103
02-05-20102

 

Thank you

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , refer if the blog on a similar topic can help

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can try this measure:

 

Result = 
VAR _date =
    SELECTEDVALUE ( 'Date Time'[Date] )
VAR tab =
    SUMMARIZE (
        ALL ( 'Table' ),
        'Table'[Code],
        'Table'[Entry Time],
        'Table'[Fired Time],
        'Table'[Ending Contract],
        "flag", IF (
            NOT ( ISBLANK ( [Fired Time] ) ),
            IF ( ( _date >= [Entry Time] && _date < [Fired Time] ), 1, 0 ),
            IF (
                NOT ( ISBLANK ( [Ending Contract] ) ),
                IF ( _date >= [Entry Time] && _date < [Ending Contract], 1, 0 ),
                IF ( _date >= [Entry Time], 1, 0 )
            )
        )
    )
RETURN
    SUMX ( FILTER ( tab, [flag] = 1 && NOT ( ISBLANK ( [Code] ) ) ), [flag] )

 

The result may your expected:

r1.pngr2.png

 

Attached my sample file that hopes to help you: Count number of employees.pbix

 

Best Regards,
Yingjie Li

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

amitchandak
Super User
Super User

@Anonymous , refer if the blog on a similar topic can help

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.