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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Jbrunson09
Frequent Visitor

Count of unique / overlapping values based on competing slicers

All,

 

First:

I'm sorry if this has been covered somewhere else already. I have looked and had no luck finding anything. Also I'm newer to PBI and DAX so I'm sorry in adavance if my terminology is incorrect.

 

The Problem:

I have 2 tables with Project ID's that both connect to a fact table which has both project ID's and Task ID's. I need to be able to dynamically filter the task ID table with project ID's selected from both of these tables using a slicer.

See below

Jbrunson09_0-1658777071808.png

 

The Goal: 

I want to be able to dynamically select a project ID from table 1 and a seperate project ID from table 2 and be able to

  1. count how many task id's are unique to the table 1 selection
  2. how many are unique to the table 2 selection
  3. how many overlap between the 2 project ID selections

See below for what this should look like in theory

Jbrunson09_1-1658777239781.png

In the example above, I can see that when project ID 1 is selected from table 1 and project ID 2 is selected from table 2 that

Only exist in Table 1 = C & D (count of 2)
Exists in Both Table 1 & Table 2 = A & B (count of 2)
Only exist in Table 2 = E (count of 1)

 

My Attempt:

Again I am new to DAX but here was my best attempt. I keep getting a blank value. I can sort of see what I want in the matrix, I just cant get a single value to display.

Jbrunson09_2-1658777575508.png

 

 

 

Here is a link to download the pbix I've been using to test:

pbix HELP 

 

 

Any help is much Appreciated!!!

 

Thank you,

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Jbrunson09 
Here is the sample file with the solution https://www.dropbox.com/t/5Zi9ofCD6nZmeBUU

1.png2.png3.png4.png

Table 1 Count = 
COALESCE(
    CALCULATE ( 
        DISTINCTCOUNT ( 'Table 3'[Task ID]),
        CROSSFILTER ( 'Table 2'[Project ID], 'Table 3'[Project ID], NONE )
    ),
    0
)
Table 2 Count = 
COALESCE(
    CALCULATE ( 
        DISTINCTCOUNT ( 'Table 3'[Task ID]),
        CROSSFILTER ( 'Table 1'[Project ID], 'Table 3'[Project ID], NONE )
    ),
    0
)
Task ID in Both Tables = 
VAR SelectedIDs1 = 
    CALCULATETABLE (
        VALUES ( 'Table 3'[Task ID] ),
        CROSSFILTER ( 'Table 2'[Project ID], 'Table 3'[Project ID], NONE )
    )
VAR SelectedIDs2 = 
    CALCULATETABLE (
        VALUES ( 'Table 3'[Task ID] ),
        CROSSFILTER ( 'Table 1'[Project ID], 'Table 3'[Project ID], NONE )
    )
RETURN
    COUNTROWS ( INTERSECT ( SelectedIDs1, SelectedIDs2 ) )

View solution in original post

2 REPLIES 2
Jbrunson09
Frequent Visitor

Thank you!!! Big help

tamerj1
Super User
Super User

Hi @Jbrunson09 
Here is the sample file with the solution https://www.dropbox.com/t/5Zi9ofCD6nZmeBUU

1.png2.png3.png4.png

Table 1 Count = 
COALESCE(
    CALCULATE ( 
        DISTINCTCOUNT ( 'Table 3'[Task ID]),
        CROSSFILTER ( 'Table 2'[Project ID], 'Table 3'[Project ID], NONE )
    ),
    0
)
Table 2 Count = 
COALESCE(
    CALCULATE ( 
        DISTINCTCOUNT ( 'Table 3'[Task ID]),
        CROSSFILTER ( 'Table 1'[Project ID], 'Table 3'[Project ID], NONE )
    ),
    0
)
Task ID in Both Tables = 
VAR SelectedIDs1 = 
    CALCULATETABLE (
        VALUES ( 'Table 3'[Task ID] ),
        CROSSFILTER ( 'Table 2'[Project ID], 'Table 3'[Project ID], NONE )
    )
VAR SelectedIDs2 = 
    CALCULATETABLE (
        VALUES ( 'Table 3'[Task ID] ),
        CROSSFILTER ( 'Table 1'[Project ID], 'Table 3'[Project ID], NONE )
    )
RETURN
    COUNTROWS ( INTERSECT ( SelectedIDs1, SelectedIDs2 ) )

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.