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 September 15. Request your voucher.

Reply
qmartiny
Helper III
Helper III

Calculating overlap between calculated columns

Hello lovely people,

 

Given this table [Account] with calculated columns [SPx].

 

Account

AccountSP1SP2SP3
AAA11 
BBB 11
CCC1  

I have created a slicer containing the SP columns so I can select from them.

However I also want to show the % overlap between SP columns ex SP1 = 100 accounts Sp2 = 70 accounts , what is the overlap between the 2?

At the moment selecting multiple SP just gives me the Total but I also want to show which accounts overlap.

 

I saw a solution that required all the groups to be within the same column. However since they are calculated columns I can not unpivot in the query.

 

Thanks for your help

 

Quentin

 



10 REPLIES 10
Anonymous
Not applicable

Hi @qmartiny ,

Could you please provide some raw data from the Account table (before creating the calculated columns SP1,SP2 and SP3)? Could you please also provide the calculation logic for these calculated columns SP1, SP2 and SP3?Later I would like to see if these columns can be created in Power Query, if so, maybe we can also use the UNPIVOT function to achieve the final result you want. Even if not, we can find out if there is an alternative way to achieve what you want...

In addition, please check out the following links using different methods(DAX and Power Query). Hope that they can help you solve the problem...

DAX:

Calculating overlap between selected groups

yingyinr_1-1636710346879.png

Power Query:

Power BI: Percent Overlap Between Groups

yingyinr_0-1636710331703.png

Best Regards

lbendlin
Super User
Super User

Familiarize yourself with the concept of INTERSECT()

 

INTERSECT function (DAX) - DAX | Microsoft Docs

 

Create temporary single column tables from your selected columns, and then use Intersect to compare them.

Hello,

 

Thank you for your reply.

 

It looks like I need to create an INTERESECT for every combination of [SP] I want to compare though.

 

Is it possible to use this like a measure so it shows overlap based on slicer selection of [SP]?

 

Thank you

Yes, that was what I suggested. Just be aware that at the end the measure needs to return a scalar value.

I am trying something like this first to isolate the SPx columns.


"Create temporary single column tables from your selected columns" - I suppose you mean a UNION like below.

 

 UNION(
SELECTCOLUMNS(_MAL,"BP",_MAL[BP_ID],"SP",_MAL[SP1]),
SELECTCOLUMNS(_MAL,"BP",_MAL[BP_ID],"SP",_MAL[SP2]),
SELECTCOLUMNS(_MAL,"BP",_MAL[BP_ID],"SP",_MAL[SP3]))

 

I understand INTERCEPT takes 2 tables max, and I could use FIRSTNONBLANK / LASTNONBLANK? to feed slicer selection ?

 

Do you have any pointers ? Thank you

 

 

Not UNION but INTERSECT. something like this:  

 

VAR A =  SELECTCOLUMNS(_MAL,"BP",_MAL[BP_ID],"SP",_MAL[SP1])
VAR B =  SELECTCOLUMNS(_MAL,"BP",_MAL[BP_ID],"SP",_MAL[SP2])
RETURN COUNTROWS(INTERSECT(A,B))

 

Thanks for that.

 

It seems to work however I have 2 issues :

 

I built a slicer using COMBINEVALUES and a UNION table so I can filter each column in one slicer.

Using your method on top I have some issues :

- When I select via slicer SP1 and SP2 I expect the value to be the same, but it returns 0. Any filtering seems to change the value, which I can understand but filtering exactly on the measure content makes the measure null.

- How do you approach making this measure dynamic ie work taking selection from the slicer? I know selectedvalue but it would only work for the first selection

 

Again thank you so much for your help.

 

I have tried using this method aswell but no luck https://community.powerbi.com/t5/Desktop/Calculating-overlap-between-selected-groups/td-p/128624

Here's where I am at the moment.. Getting a blank result where it should work in theory?

 

Overlap =

VAR MaxSelect = MAX('SP Select'[Selection])
VAR MinSelect = MIN('SP Select'[Selection])

VAR A =  SELECTCOLUMNS(_MAL,"BP",_MAL[BP_ID],"SP",MaxSelect)
VAR B =  SELECTCOLUMNS(_MAL,"BP",_MAL[BP_ID],"SP",MinSelect)

RETURN 
COUNTROWS(INTERSECT(A,B))

 

your first two variables get you a scalar value, not a column. You can still do an intersect but it will only test if these scalar values match.

 

If you cannot hard code the column names then you need to use measures. But you mentioned that these are calculated columns in the first place.  Maybe explain the setup in more detail.

Hm. I am stuck since my slicer doesnt have the same name as my column header anyway..

 

I'll try using a UNION table to unpivot the data see if that's easier.

 

Thanks 

 

 

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.