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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
luis2810
Frequent Visitor

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
2 REPLIES 2
v-yingjl
Community Support
Community Support

Hi @luis2810 ,

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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