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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
BINewbie1
Helper II
Helper II

Team Referrals from the context of each team

Hello,

 

I'm trying to create a report that based on a simple referral process between teams, for example, say there are three teams and the refer clients between them. There's a receiving team, and what I've called the actioning team - data is logged by the team that makes the referal, the actioning team. Each team referrs clients to the other two teams.

 

I've trying to create a tables for each team that would show the number of referrals made to the other teams, with the team names listed in that table. I'm finding it hard to create a filter context that will show referals in both directions for each team. I can count them easily enough, but not list out the actioning team and receving team for each of the different teams. Hope that makes sense - example of what I need at the bottom.

 

The Referrals Data is in this format, and it using a Team ID to connect through relationship to a single team dimension table:

 

Referral IDActioning TeamReceiving Team
1AB
2BC
3CA
4AC
5BA

 

My current data model is fairly simple (but maybe wrong) with two inactive relationships between the Teams Dimention table, and the Referrals fact table.

 

BINewbie1_0-1733481919050.png

 

Here's the pbix file:

From - To Test.pbix 

 

What I want to get to will look like this, a income and outgoing table from the perspective of each team. There's only 5 referrals, but separated into the Team Context, the sum total would be 10, due to the double counting amungst the receiving and actioning teams.

 

     
Team Alpha (Incoming) Team Alpha (Outgoing)
Team Name (Actioning)No.  Team Name (Receiving)No.
Bravo1 Bravo1
Charlie1 Charlie1
     
     
Team Bravo (Incoming) Team Bravo (Outgoing)
Team Name (Actioning)No.  Team Name (Receiving)No.
Alpha1 Alpha1
Charlie0 Charlie1
     
     
Team Charlie (Incoming) Team Charlie (Outgoing)
Team Name (Actioning)No.  Team Name (Receiving)No.
Alpha1 Alpha1
Bravo1 Bravo0

 

Not sure whether the answer is in the data modelling, or a clever filter context in DAX? I think a merged query between the tables would probably would, so that I could use the new columns (with the team names) in the tables - but merged queries always seems to slow down the report, and create refresh errors - so I'd like another way.

 

Many thanks,

 

Adam

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You need another copy of the Teams table, which you can make like

Teams for slicer = Teams

Create the same inactive relationships from this new table to the Referrals table, and use this table in the slicer.

Create a calculation group with 2 calculation items,

Incoming = CALCULATE(
    SELECTEDMEASURE(),
    USERELATIONSHIP( 'Teams for slicer'[Team ID], Referrals[Receiving Team] ),
    USERELATIONSHIP( Teams[Team ID], Referrals[Actioning Team] )
)

Outgoing = CALCULATE(
    SELECTEDMEASURE(),
    USERELATIONSHIP( 'Teams for slicer'[Team ID], Referrals[Actioning Team] ),
    USERELATIONSHIP( Teams[Team ID], Referrals[Receiving Team] )
)

and finally create a measure like

Num referrals = COUNTROWS( Referrals )

Put the name from the original Teams table in a matrix with the [Num referrals] measure and the put the calculation group on the columns.

See the attached PBIX for a sample.

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

You need another copy of the Teams table, which you can make like

Teams for slicer = Teams

Create the same inactive relationships from this new table to the Referrals table, and use this table in the slicer.

Create a calculation group with 2 calculation items,

Incoming = CALCULATE(
    SELECTEDMEASURE(),
    USERELATIONSHIP( 'Teams for slicer'[Team ID], Referrals[Receiving Team] ),
    USERELATIONSHIP( Teams[Team ID], Referrals[Actioning Team] )
)

Outgoing = CALCULATE(
    SELECTEDMEASURE(),
    USERELATIONSHIP( 'Teams for slicer'[Team ID], Referrals[Actioning Team] ),
    USERELATIONSHIP( Teams[Team ID], Referrals[Receiving Team] )
)

and finally create a measure like

Num referrals = COUNTROWS( Referrals )

Put the name from the original Teams table in a matrix with the [Num referrals] measure and the put the calculation group on the columns.

See the attached PBIX for a sample.

Thanks @johnt75,

 

That looks good. I'll spend some time getting my head around it, but it works as needed.

 

I was looking for a reason to get into Calulation Groups, which I've not looked at yet.

 

Many thanks,

 

Adam

bhanu_gautam
Super User
Super User

@BINewbie1 , Create measures to count the incoming and outgoing referrals for each team.


Outgoing Referrals =
CALCULATE(
COUNTROWS(Referrals),
USERELATIONSHIP(Referrals[Actioning Team], Teams[Team ID])
)

// Measure for counting incoming referrals
Incoming Referrals =
CALCULATE(
COUNTROWS(Referrals),
USERELATIONSHIP(Referrals[Receiving Team], Teams[Team ID])
)

 

 

Create tables to display the incoming and outgoing referrals for each team.

DAX
// Table for Incoming Referrals
Incoming Referrals Table =
SUMMARIZE(
Referrals,
Teams[Team Name],
"No. of Incoming Referrals", [Incoming Referrals]
)

// Table for Outgoing Referrals
Outgoing Referrals Table =
SUMMARIZE(
Referrals,
Teams[Team Name],
"No. of Outgoing Referrals", [Outgoing Referrals]
)

 




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hi @bhanu_gautam,

 

Thanks for your assistance.

 

I should have said, one of the complications I have from the actual data model is that there are about 60 teams, and If its possible, i'd rather not have to write 120 measures, and add 60 tables to my model.

 

Is there a way of writting a pair of generic measures where by the filter context (either a filter or a slicer) would allow the team to be selected and show that team's incoming and outgoing referals. I guess it would all be done in virtual tables, which will be ok.

 

Many thanks,

 

Adam

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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