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
AnetaK
Helper V
Helper V

HR issue with DAX - first occurence of an employee after filtering

Hello,

 

I have this table with employees.

AnetaK_0-1633010889003.png

It has a relation with Calendar table.

 

My task is to create a measure that shows new hires first occurances on the date axis (edit: I want to show first occurance of the employee).

Now it's just a simple DAX: Hires = DISTINCTCOUNT('Employee'[Name]).

So we have such a table in PBI.

AnetaK_0-1633012463687.png

 

How to write this DAX so that:

- there is only one occurence ( 01/01/2019) when no filter is applied;

- when there's a filter Level=Mid there's a new hire an occurence only on 01/01/2019 and when there's a filter Level=Senior there's a new hire one only on 01/01/2021;

- when there's a filter Team=Bob there's a new hire only one occurence on 01/08/2021 ?

 

I'm stuck. Please, help.

 

5 REPLIES 5
AnetaK
Helper V
Helper V

Nobody? 😞

AnetaK
Helper V
Helper V

There is one employee - John Doe. We have his history in the table.

He started as a Mid in Anna's Team, then got promoted to Senior and later changed his team.

dedelman_clng
Community Champion
Community Champion

@AnetaK - you use case doesn't make sense then. The data does not support what you're asking, as there are 3 employees (with no filter), 2 Senior (with a filter on senior), 2 on Team Bob (with a filter on team).

 

Perhaps you can restate your use case / requirements?

 

David

AnetaK
Helper V
Helper V

It's the same on the line chart. It's just easier here to show it on the table.

AnetaK_0-1633018912781.png

 

Using COUNTROWS(Employee) instead of DISTINCTCOUNT makes no change.

 

 

dedelman_clng
Community Champion
Community Champion

Hi @AnetaK -

 

Don't create the table like you did. Just use the Start Date (or the Calendar date) as the X-axis, value is COUNTROWS(Employee).  Your filter will redraw the chart when you use them.

 

Hope this helps

David

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.

Top Solution Authors