Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Let's say I have 2 tables both of email address: Table1: Email Subs ("Subs") and Table2: Registered Users ("Registereds"). The intersection between these is straight forward, and I do the following -- which is 2 VARs of distinct columns and the intersection, as below:
What if, however, the second table is instead a user number and I dont want to lard up the 2nd table with a lookupvalue (that would add a column with the usernumber's email....) and instead want to do that in memory, and the lookupdate of user # and user email is an inactive relationship. What's the best path? Var with lookupvalue fails on the indirect. I suppose I could do a calculatetable and then select columns?
Any advice for what's the most efficient? Some kind of related function?
Thank you
Charlie
Solved! Go to Solution.
@charleshale , if both tables have email ids you can use intersect
Var _tab = intersect(all(Table1[email]), All(Table2[email]))
return
calculate(count(Table1[email]), filter(Table1,Table1[email] in _tab))
But if the tables are joined. then the inner join will give common values
in a visual table2[email] and count(Table1[email]) should do
So, here's the best I have been able to get: merge 2 tables thru a CROSSJOIN and then select the column. That works.........Not so elegant AND PAINFULLY SLOW but does the job
~overlap_
VAR _table1 =
DISTINCT ( Table1[Email] )
VAR _table2 =
SELECTCOLUMNS(
CROSSJOIN(Table2, LookupTable), //table2 has registered users by #
"RegUsersEmail", LookupTable[Email])
VAR _Intersect =
INTERSECT ( _table1, _table2 )
RETURN
COUNTROWS ( DISTINCT ( _Intersect ) )
Hi, @amitchandak, ever present super-user extraordinaire.
The intersect would be only 1 row between tables 1 and 2 (Jim@yahoo.com)
The question is what's the best way to code an intersect function if I want to use a related table #3 as the lookup instead of the obvious way of simply adding an email address column to table2 via lookupvalue()? Sorry - important note: assume Table3 is only an inactive relationship so I might need to use TreatAs or UserRelationship
Why I persist in trying to find harder ways to do things is a separate question altogether!
@charleshale , I am not 100% sure, I got what output you want. Please find the attached file after the signature, if that can help
Please note that the link you have shared is having other content too. Please hide that if everything is not a public file.
That would work -- nice job -- but how would you do it user intersect ()? The question I am fundamentally interested in is the intersect between a column in 2 tables when the relationship is indirect. For example, in the real world, counting the overlap between registered users and email subs when one is an email address and the other expresses itself as a hash that I have to look up through an intermediate table.
So, here's the best I have been able to get: merge 2 tables thru a CROSSJOIN and then select the column. That works.........Not so elegant AND PAINFULLY SLOW but does the job
~overlap_
VAR _table1 =
DISTINCT ( Table1[Email] )
VAR _table2 =
SELECTCOLUMNS(
CROSSJOIN(Table2, LookupTable), //table2 has registered users by #
"RegUsersEmail", LookupTable[Email])
VAR _Intersect =
INTERSECT ( _table1, _table2 )
RETURN
COUNTROWS ( DISTINCT ( _Intersect ) )
PS a crossfilter would work but that requires a calculate function.
@charleshale , Yes crossjoin is another good option. Just be careful, it might be costly on bigger data.
@charleshale , if both tables have email ids you can use intersect
Var _tab = intersect(all(Table1[email]), All(Table2[email]))
return
calculate(count(Table1[email]), filter(Table1,Table1[email] in _tab))
But if the tables are joined. then the inner join will give common values
in a visual table2[email] and count(Table1[email]) should do
@charleshale , Not very clear. Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
You can create a common email Table
Measure =
var _T1 = distinctcount(Table1[email])
var _T2 = distinctcount(Table2[email])
return
countx(filter(summarize(Table3, Tabl3[email],"_1",_T1, _2,_T2), [T1] >0 && [T2]>0),[email])
should give you common between Table1, and Table 2
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
143 | |
72 | |
62 | |
51 | |
48 |
User | Count |
---|---|
206 | |
90 | |
61 | |
59 | |
57 |