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

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

Reply
Anonymous
Not applicable

Dynamic count the occurrence based on slicers

Dear everyone,

I have dataset with the below structure:

FactoryPersonType
Factory 3person 100Type 1
Factory 3person 100Type 16
Factory 3person 100Type 6
Factory 3person 101Type 1
Factory 3person 101Type 21
Factory 3person 101Type 22
Factory 3person 101Type 23
Factory 3person 101Type 6
Factory 3person 102Type 1
Factory 3person 102Type 16
Factory 3person 102Type 23
Factory 3person 102Type 6
Factory 3person 103Type 1

 

I use Factory and Type as filters. And I want to count number of unique persons with the selected types.

 

For example, if I select Type as "Type 1", "Type 22", "Type 23" then there is a measure that shows the number of persons which 3 above types only.

 

Here is the file

http://www.mediafire.com/file/kf9pg8d9wz7kjnw/Count_the_filtered_only.pbix/file

 

Can you please help me out?

 

Thank you in advance!

 

Best regards,

Cindy

3 REPLIES 3
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.

 

Best Regards

Allan

 

 

v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, you may create a measure as below.

 

Result = 
var _num = 
CALCULATE(
    DISTINCTCOUNT(Sheet4[Type]),
    ALLSELECTED(Sheet4)
)
var tab = 
SUMMARIZE(
    Sheet4,
    Sheet4[Person],
    "flag",
    IF(
      DISTINCTCOUNT(Sheet4[Type])=_num,
      1,0
    )
)
return
CALCULATE(
    DISTINCTCOUNT(Sheet4[Person]),
    FILTER(
        tab,
        [flag]=1
    )
)

 

 

Result:

x1.PNG

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , do you having all three types. Because having one of the three is the default behavior

Try like

measure =
var _cnt = countx(allselected(Table), Table[Type])
return
countx(filter(summarize(table, table[person], "_1", countrows(Table)),[_1]=_cnt),[person)

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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