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

How to add filter for worker status - Active, Exited and Pending

Hello,

I would like to add a filter in the Power BI report to select whether the employee is Active, Pending, or Exited.

paragchapre1_0-1633355210766.png

 

Below is my data.

Employee nameEmployment start dateEmployment end date
John01/01/2021Never
Adam01/01/201001/01/2021
Celina12/12/2021Never
Jennifer05/07/2021Never

 

How can I achieve this in Power BI?

 

For the active employees:  The employment start and end dates are between the current date.

employment start date<=  current date && employment end date >= current date

 

For the Exited employees:  This should be past employees. The employment end date should be less than the current date

 

For the Pending employees: These should be future employees which means the employment start date is greater than the current date.

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@Anonymous  you need a calculated column for slicer as following

 

Column = switch ( TRUE(), Emp[Employment end date]="Never", "Active", Emp[Employment start date]>=TODAY(),"Pending", CONVERT(Emp[Employment end date],DATETIME)<TODAY(),"Exited")

 

smpa01_0-1633357218619.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

6 REPLIES 6
smpa01
Super User
Super User

@Anonymous  you need a calculated column for slicer as following

 

Column = switch ( TRUE(), Emp[Employment end date]="Never", "Active", Emp[Employment start date]>=TODAY(),"Pending", CONVERT(Emp[Employment end date],DATETIME)<TODAY(),"Exited")

 

smpa01_0-1633357218619.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@smpa01 

You need to swap the order of the first and second clause in the SWITCH Statement.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Thanks @PaulDBrown ; please give the above a try @Anonymous 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
smpa01
Super User
Super User

@Anonymous  "I would like to add a filter in the Power BI report to select whether the employee is Active, Pending, or Exited." - based on what logic?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

I edited the post and added logic.

Anonymous
Not applicable

Thanks the solution works.

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.