Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi everyone,
I have a dimension table dim_hr_employment_details where there is the hire date and the termination date of each employee, and a DimDate (calendar) table. In my model there is an active relationship between both tables using the termination date of dim_hr_employment_details and the date of DimDate, and an inactive relationship using respectively the hire date and the date.
In my report, I have a slicer that simply uses the date from DimDate.
And when selecting e.g. 2022 in the slicer, I would like to compute a measure that counts the number of employees for which the slicer date value (in this case ; 01/01/2022) is between their hire date and termination date.
Could someone help me out with that?
Thanks a lot!
Solved! Go to Solution.
hi @alocoo
Your logic is very clear. Not sure about your dataset. You may
1) create an isolate datetable
2) write a measure like this:
ActiveEmp =
VAR _date = SELECTEDVALUE(DateTable[Date])
RETURN
COUNTROWS(
FILTER(
TableName,
TableName[HireDate]<=_date
&&TableName[EndDate] >= _date
)
)
3) plot a slicer with the date column from the datetable and another visual (e.g. Card) with the measure.
I tried and it worked like this:
the sample dataset:
the datetable:
To use slicer value as filter boundary, the sliced table shall be isolated. Otherwise, the slicer filters a single value.
Hi @FreemanZ ,
so I would like to create a measure that includes the date that I select in my date slicer.
If I create a simple measure that counts the number of employees and I put it in a visual, when I select for example 2022 in my date slicer I will only have the number of employees whose termination date (or hire date if I use the inactive relationship) is 2022. But what I would like to have is a measure that counts the number of employees for which the value in my date slicer (e.g. 2022) is bigger than their hire date AND smaller than their termination date.
Thanks!
hi @alocoo
Your logic is very clear. Not sure about your dataset. You may
1) create an isolate datetable
2) write a measure like this:
ActiveEmp =
VAR _date = SELECTEDVALUE(DateTable[Date])
RETURN
COUNTROWS(
FILTER(
TableName,
TableName[HireDate]<=_date
&&TableName[EndDate] >= _date
)
)
3) plot a slicer with the date column from the datetable and another visual (e.g. Card) with the measure.
I tried and it worked like this:
the sample dataset:
the datetable:
To use slicer value as filter boundary, the sliced table shall be isolated. Otherwise, the slicer filters a single value.
Thanks a lot @FreemanZ, however as in my data model there is an active relationship between the end date and the date of the datetable, but an inactive one between the hire date and the date of the datetable, it returns blank when I create the measure you wrote. What should I do differently in the measure?
hi @alocoo
you are welcome. Then create an new isolated date table for the slicer.
@FreemanZ I've created another date table DimDate2 and here is now my formula :
hi @alocoo
both DimDate and DimDate2 need to be isolated from the dim_hr_employment_details table. Is that so in your case?
Hi @alocoo
I mean delete all the relationships for the tables that you put into a slicer to get the filter boundaries.
hi @alocoo
could you further explain the logic of this part:
when selecting e.g. 2022 in the slicer, I would like to compute a measure that counts the number of employees for which the slicer date value (in this case ; 01/01/2022) is between their hire date and termination date.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 23 | |
| 12 | |
| 11 | |
| 10 | |
| 9 |