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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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

Top Kudoed Authors