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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Lara1105
New Member

Multiple selection of dates in filter slicer working for a measure

Hello Community,

I am still very new to Power BI and especially DAX coding. I am trying my best to describe my problem:

 

I have two tables,
Active[ID]: numeric, one ID per doctor
Active[DateFrom]: start date
Active[DateTo]: end date or blank if ID is still valid
this table includes all active doctors that do exist in a specific area
and then I have another table which includes only those doctors who offer an appointment at a date in this specific area:
Appointment[ID]: numeric, one ID per docotor
Appointment[Date]: date


I want to set the number of doctors that offer appointments in relation to the number of all existing doctors and I want to do this by filtering a date.
For Appointment[ID] I can simply use DISTINCTCOUNT and a filter slicer, no problem.
But the filter slicer is not so easily working for the Acitve[ID] as I have a date from and date to there.
So I need DISTINCTCOUNT(Active[ID]) to change when selecting dates via my filter slicer of Appointment[Date].
With the help of google and the following measure I made it so far that this distinctcount changes when I select one date and when no date (so all dates) are selected:


PickThis =
var _selectedDate = SELECTEDVALUE(Appointment[Date])
return
IF(
ISBLANK(_selectedDate), CALCULATE(DISTINCTCOUNT(Active[ID])),
CALCULATE(DISTINCTCOUNT(Active[ID]), ALL(Active[DateFrom],Active[DateFrom]), Active[DateFrom] <= _selectedDate && (Active[DateTo] >= _selectedDate || ISBLANK(Active[DateTo] )))
)


Still missing is the case of multiple selections. At the moment I get the same numbers as if no data is seleced. Can anybody help?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Lara1105 , Seem like very similar to the HR blog

Power BI: HR Analytics - Employees as on Date: https://youtu.be/e6Y-l_JtCq4
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

 

If need use the file attached

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Lara1105
New Member

Thank you so much, this helped me for remodeling my measure!

amitchandak
Super User
Super User

@Lara1105 , Seem like very similar to the HR blog

Power BI: HR Analytics - Employees as on Date: https://youtu.be/e6Y-l_JtCq4
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

 

If need use the file attached

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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