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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
RichardP
Helper I
Helper I

Analyse data that is in one table but not another

Hi everyone,

 

I have a Measure which I'm using to calculate potential users of a website (based on unique Visitor IDs in the Users table) HAVE visited (based on if their Visitor ID is in the related Visits table)

 

Website visitors = CALCULATE(DISTINCTCOUNT('Visits'[Visitor ID]),FILTER('Visits','Visits'[Visitor ID] IN DISTINCT('Users'[Visitor ID])))

 

I'd like to also flip this around and count how many of the potential users HAVE NOT visited.

 

I've tried a couple of basic calculations like counting the distinct User IDs in the Users table and then just deducting the number of users who did visit. However, I found that this measure would not work if I tried to add an additional Axis to the presentation of the data like Month (The Visits table has multiple entries for each user, one for each Month to which the data relates).

 

Any advice would be very welcome!

 

Best wishes,

Richard

1 ACCEPTED SOLUTION

@RichardP- Try this:

 

mDidntVisit = 
VAR tmpVisited = SELECTCOLUMNS(Visits,"User ID",[User ID])
VAR tmpUsers = ALL(Users[User ID])
RETURN COUNTROWS(EXCEPT(tmpUsers,tmpVisited))

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

I think that maybe EXCEPT could be used here. But, need data to recreate. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

 

Thank you for the reply, I've had a look at EXCEPT but can't quite figure it out.

 

Thanks also for the feedback on useful information.  Here's some more detail:

 

Users table has a list of unique users based on unique User IDs

User IDName
111John
222Bill
333Jane
444Sarah
555Alex
666Ben
777Tony

 

This table has a one-to many bi-directional relationship with the Visits table which has this data:

 

User IDVisitsMonth
1115January 2018
1115February 2018
1114March 2018
22228March 2018
333106January 2018
333158March 2018
4447January 2018
77728March 2018

 

So what I'm trying to make is a month-by-month count of how many users in the users table didn't visit the site, eg: January count would be 4, February count would be 6, etc. I've been doing this by putting the Month field onto the Axis.

 

The closest I've managed to get is:

Non-visitors = COUNTROWS(FILTER(SUMMARIZE('Users','Users'[User ID],"calc",SUM('Visits'[Visits])),[calc]=0))

 

Which works for a global total but only returns 0 when i add the Month into the axis or add a single Month as a filter.

 

 

Thanks again for any suggestions!

@RichardP- Try this:

 

mDidntVisit = 
VAR tmpVisited = SELECTCOLUMNS(Visits,"User ID",[User ID])
VAR tmpUsers = ALL(Users[User ID])
RETURN COUNTROWS(EXCEPT(tmpUsers,tmpVisited))

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.