Forum Discussion
Using Date Slicer as Variable in a Measure
Hi Power BI Community,
I've ran into an issue when trying to use a date slicer as a variable in a measure. The case is as follows:
- I have a list of people who have two dates associated with them, DateOnHold and DateOffHold.
- The user will control a date slicer to select a calendar month.
- The measure should calculate the number of people who were on hold going into the selected month and ignore people who came off hold before the selected month.
A sample of the data table looks like:
| ID | OnHold | OffHold |
| 1 | 01/03/2017 | 01/04/2017 |
| 2 | 12/08/2019 | 12/08/2020 |
| 3 | 06/04/2020 | 06/08/2020 |
| 4 | 21/05/2020 | |
| 5 | 08/12/2018 | 28/12/2018 |
| 6 | 16/09/2019 | 01/01/2020 |
| 7 | 31/07/2020 | |
| 8 | 15/03/2019 | 04/05/2019 |
| 9 | 27/11/2018 | 05/12/2018 |
In this instance, I would like to use a date slicer to select 01/08/2020 - 31/08/2020 and it return a count of 4 as two records have no defined OffHold date and the other two's end date is later than the first date of the month selected. Furthermore, if there is a handy way to summarise this into a table to see the people currently on hold as well based on the user inputted slicer, that would be amazing.
My attempt hasn't worked well:
| ID | OnHold | OffHold |
| 1 | 01/03/2017 | 01/04/2017 |
| 2 | 12/08/2019 | 12/08/2020 |
| 3 | 06/04/2020 | 06/08/2020 |
| 4 | 21/05/2020 | |
| 5 | 08/12/2018 | 28/12/2018 |
| 6 | 16/09/2019 | 01/01/2020 |
| 7 | 31/07/2020 | |
| 8 | 15/03/2019 | 04/05/2019 |
| 9 | 27/11/2018 | 05/12/2018 |
Cheers,
cmob
Anonymous , refer my blog HR on similar kind of data can help on this
3 Replies
- amitchandakSuper User
Anonymous , refer my blog HR on similar kind of data can help on this
- AnonymousNot applicable
Thanks for sending me this, it looks exactly what I'm after. I'm going to try it and if it fixes my issue I'll mark as solution.
Cheers,
cmob
- AnonymousNot applicable