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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Multiples dates in one table

Hi

 

I have the following problem. I have a table with information of all the employees who are active and inactive of the company. In this table i have a date of admission and for those inactive employees date of leave. I want to have a visualization that shows de increase of employees through months. Example table information:

IDEmployeeDate of admissionDate of leaveActive
1Juan1/1/2019 Yes
2Maria7/6/2003 Yes
3Pedro6/5/20207/6/2022No
4Ulises6/8/20188/5/2021No
5Roberto7/9/2019 Yes
6Lucia2/3/2015 Yes

 

Dax formula i used:

Headcount = CALCULATE(DISTINCTCOUNT(Empleados[Employee]), Empleados[Active] ="Yes")

Historic Headcount=

CALCULATE(
    [Headcount],
    FILTER(
        ALLSELECTED('Date'[Date]), 'Date'[Date] <= MAX ('Date'[Date])
        
    ))
 
I have a Date table relation with Date of Admission o Employee table. Anda i have an INACTIVE relation between Date of Leave and Date table.
When i show the visualization i realise that de cummulative headcount in time it is only counting for each mont employees that enter the company. So the number is always increasing. It doesent count in each month the employees which where active in a mont but now they are not active because they leave
Please Help

Thanks!
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

4 REPLIES 4
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, you want to show in the current Date from Date table, how many employees are there with active status. here's my solution.

1. Don't make any relationship between Empleados and Date table.

2. Create a measure.

Historic Headcount =
CALCULATE (
    DISTINCTCOUNT ( Empleados[Employee] ),
    FILTER (
        ALLSELECTED ( Empleados ),
        'Empleados'[Date of admission] <= MAX ( 'Date'[Date] )
            && (
                'Empleados'[Date of leave] = BLANK ()
                    || 'Empleados'[Date of leave] >= MAX ( 'Date'[Date] )
            )
    )
)

Get the correct result.

vkalyjmsft_0-1664877324796.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

Anonymous
Not applicable

Thank uuu!

it solved my problem!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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