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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
peterwalken
Frequent Visitor

Filter the same table two times with item slicer

Hi community,

 

I have two tables

People table:

People namePeople id
Amy001
Peter002
Paul003

 

Poject table:

People IDproject ID
001XX
001YY
001ZZ
002XX
002YY
003ZZ
004ZZ
004QQ

 

image.png

I connected two tables with one to many relationship by People ID.

 

My task is that once the people name is selected in the slicer, I need to calculate number of people participate in the same project.

 

For example, If I select Amy in the slicer, Amy participated in Project XX, YY and ZZ, and I see people ID 002, 003, 004 also participated in the projects that Amy has participated in, so the total number of people partcipated in Amy's project are 4 (001, 002, 003, 004).

 

I tried to extract the list of project that Amy has partcipanted in with below measure

 

 

Number of related project = 
var selectedPeople = SELECTEDVALUE(People[People Name])
return
    calculate(
        distinctcount(project[project ID]),
        People[People Name] = selectedPeople 
    )

 

 

This measure only count the number of projects Amy has partcipating.

image.png

 

The question is how to distinct count the number of people who share the same project with selected people in slicer?

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@peterwalken , In sunc case prefer to use an independent people table

 

Number of related project =
var _tab = summzarize(filter(project, project[People ID] in SELECTEDVALUE(People[People ID])), [Project ID]
return
calculate(
distinctcount(project[project ID]),filter( project, project[Project ID] in _tab))

 

or when joined

 

Number of related project =
var _tab = summzarize(filter(project, project[People ID] in SELECTEDVALUE(People[People ID])), [Project ID]
return
calculate(
distinctcount(project[project ID]),filter( project, project[Project ID] in _tab), removefilter(People) )

Hi @amitchandak,

 

Thanks for replying. Could you explain more on two measures you provide?

I tried to create those measure, but there are syntax error in the var _tab.

image.png

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.