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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Jyaul1122
Helper I
Helper I

Get all employee name in selected Date period

Hello all,Greeting,

I have Employee table and Company with are related with Company column.

Employee table:

CompanyEmployee nameDate of Join
P1Emp130-Mar-24
P1Emp230-Apr-24
P1Emp930-May-24
P1Emp430-Jun-24
P1Emp530-Jul-24
P2Emp730-Nov-24
P2Emp830-Sep-24
P2Emp1230-Dec-24
P3Emp2130-Dec-24
P3Emp2230-Jan-25
P3Emp2325-Feb-25
P3Emp2926-Mar-25
P3Emp2507-Apr-25

 

and Compnay table:

Company
P1
P2

and also Employee table is related with Calendar table via Date of Join. I have Month slicer(single select) from Calendar Table in my report. Month slicer:

Jyaul1122_0-1734446063318.png

Requirements: I want to get table with  Project name and the all Employee name who join between dates Date(2024,01,01) and selected date from Slicer. For example when I select Sep 24 from slicer, Result will be: 

CompanyEmployee_ 
P1Emp1
P1Emp2
P1Emp9
P1Emp4
P1Emp5
P2Emp8

I tried to write measure like : Employee_=Calculate(max(employee name),datesbetween(Calendar[date],Date(2024,01,01),max(calendar[Date])) but thats not work. How can I do using DAX.

Could you please help ?

6 REPLIES 6
DataNinja777
Super User
Super User

Hi @Jyaul1122 ,

 

Here is the measure for your required output.

Show Employees = 
VAR SelectedDate = MAX('Calendar'[Date])
RETURN
IF(
    'Employee'[Date of Join] >= DATE(2024, 1, 1) &&
    'Employee'[Date of Join] <= SelectedDate,
    1, 
    0
)

Add Company and Employee name to a table visual, then apply the Show Employees measure as a filter where the value equals 1. This will display only rows that satisfy the condition without aggregating the names.

 

Best regards,

Thanks for your reply, I can not apply filter because I have a lot off measures and fields in table visual. Filter will impact to another measures also.

123abc
Community Champion
Community Champion

Use the following DAX to define a new measure that checks for employees whose joining date falls in the required range:

 
Employee_Filtered = VAR SelectedDate = MAX('Calendar'[Date]) RETURN CALCULATETABLE( VALUES('Employee'[Employee name]), 'Employee'[Date of Join] >= DATE(2024, 1, 1) && 'Employee'[Date of Join] <= SelectedDate )

Step 2: Create a Table Visual

  1. Add a Table Visual to your report.
  2. Drag the Company column from the Employee table.
  3. Add the Employee_Filtered measure (this will dynamically return employee names).

Step 3: Adjust the Table to Show Filtered Data

If you want to ensure the table filters correctly when you select a month in the slicer, Power BI's relationship between the Calendar table and the Employee table will take care of the filtering.


Troubleshooting Tips:

  1. Ensure the Employee[Date of Join] column is properly related to the Calendar[Date] column.
  2. Make sure your Month Slicer comes from the Calendar table.
  3. If the measure doesn't show the desired result in a table visual, you can use this as a calculated column instead.

Final Output:

When you select September 2024 in the slicer, the table will display:

Company Employee name
P1Emp1
P1Emp2
P1Emp9
P1Emp4
P1Emp5
P2Emp8

Let me know if you need further clarification or adjustments!

@123abc 

I tried with your idea but I got single value on Sep 24, P2 Emp 8.

I thinks , its filter rows based on Month selection. I also tried with remove relation between calendar table but got error: A table of multiple values was supplied where a single value was expected.

If you have pbix please share.

123abc
Community Champion
Community Champion

 

Thank you for the clarification. The issue lies with the filtering behavior. Since the slicer is single-select and filters the data to a single date (or month), we need to modify the approach slightly. Here is a correct DAX solution to achieve your goal without breaking relationships.


Key Considerations:

  1. You need a list of employees who joined between January 1, 2024, and the end of the selected month.
  2. A calculated column or measure needs to respect the selected slicer value but avoid filtering down to just one month.

Solution 1: Use a Calculated Table (Static Table)

This creates a calculated table in your model.

 

 
Filtered_Employees = VAR SelectedDate = MAX('Calendar'[Date]) RETURN SUMMARIZE( FILTER( 'Employee', 'Employee'[Date of Join] >= DATE(2024, 01, 01) && 'Employee'[Date of Join] <= SelectedDate ), 'Employee'[Company], 'Employee'[Employee name] )

 

Steps to Add This Table:

  1. Go to the Modeling tab in Power BI.
  2. Select "New Table" and paste the above DAX.
  3. Use this new table (Filtered_Employees) in your visuals.

Solution 2: Create a Dynamic Measure

If you want to display this dynamically in an existing table visual:

 

Filtered Employee Name = VAR SelectedDate = MAX('Calendar'[Date]) -- Slicer selected date RETURN IF ( MAX('Employee'[Date of Join]) >= DATE(2024, 01, 01) && MAX('Employee'[Date of Join]) <= SelectedDate, MAX('Employee'[Employee name]), BLANK() )

Steps to Apply:

  1. In your table visual:
    • Add Company from the Employee table.
    • Add the Filtered Employee Name measure.
  2. This will dynamically filter and show results.

Solution 3: Avoiding Relationships Filtering the Calendar Table

If your slicer filters the Employee table directly due to relationships, try removing the slicer impact on the Employee table:

Updated Measure Using REMOVEFILTERS:

 

Filtered Employees = VAR SelectedDate = MAX('Calendar'[Date]) RETURN CALCULATETABLE( VALUES('Employee'[Employee name]), REMOVEFILTERS('Calendar'), -- Remove slicer impact FILTER( 'Employee', 'Employee'[Date of Join] >= DATE(2024, 01, 01) && 'Employee'[Date of Join] <= SelectedDate ) )

This measure ignores slicer filters and manually applies conditions.


Testing and Results

Once you apply the solutions:

  • For September 2024, you should see:Company Employee Name
    P1Emp1
    P1Emp2
    P1Emp9
    P1Emp4
    P1Emp5
    P2Emp8

Let me know if you'd like me to create and share a sample PBIX file! 🚀

Its not working , same result as previous. Could you please share pbix ?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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