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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
ankita_7
Helper II
Helper II

Distinct resident count according to date slicer

I have a table with columns as resident name, resident ID, hospital name and visited date of every resident. In date slicer I'm using visited date. If I select 1/1/2020 to 1/31/2020 then I should get only that period distinct visited count in that hospital of that resident using resident ID. I 'm using a measure to calculate this count but I'm getting sum of the count for that resident ID in its overall visited period in the hospital and not according to date slicer.

 

Like if I select two months i.e date from 1/1/2020 to 2/29/2020  then it should give me sum count of that resident ID in that hospital for only two months.

 

Can anyone help me with this problem?

Thanks in advance.

7 REPLIES 7
Anonymous
Not applicable

HI @ankita_7,

It sounds like you want to achieve an indirect filter based on the first selection.
If this is a case, I'd like to suggest you extract all resident id to create an unconnected table and use it as the source of the slicer.
You can write a measure to compare current row contents and selected date range(selected resident id date range) and return tag.  After these steps, you can use this measure on 'visual level filter' to filter records.

Measure =
//selector is a new table with all Resident id
VAR selected =
    ALLSELECTED ( selector[ID] ) 
//extract date range based on selected id
VAR dateRange =
    CALCULATETABLE (
        VALUES ( Resident[Date] ),
        FILTER ( ALLSELECTED ( Resident ), Resident[ID] IN selected )
    )
RETURN
    CALCULATE (
        COUNTROWS ( VALUES ( Resident[ID] ) ),
        FILTER ( ALL ( Resident ), Resident[Date] IN dateRange )
    )

If above not help, please share some dummy data with the expected result to help us clarify your scenario and test to coding formula on it.
Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Can you post the measure you're using?

Measure I'm using to count is:
All Count = CALCULATE(COUNT('table'[PatientID]),ALLEXCEPT('table',
'table'[Resident]))
Anonymous
Not applicable

@ankita_7, in the measure you're using, ALLEXCEPT, is removing all of the filters except for those applied to 'table'[Resident] 

 

Try using the measure below without the ALLEXCEPT function.

 

 

All Count = COUNT('table'[PatientID])

 

 

or if the ALLEXCEPT function is needed for other reasons, add the date column to the ALLEXCEPT function.

 

 

All Count = CALCULATE(COUNT('table'[PatientID]),ALLEXCEPT('table','table'[Resident],'table'[visited date]))

 

Okay. I tried this one. But its not taking the date column.

Anonymous
Not applicable

What error are you getting? The ALLEXCEPT function should be able to take multiple columns.

It wasn't showing me the date column name and other column it took i.e. patient ID.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors