March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
Hi all,
I have a 'Userlist' table where each user (email) be connected to one or more regions, like this:
Next, I have a region dim table connected to all relevant fact tables.
I would like to perform a lookup to limit each user to see only the regions they are connected to, but I don't know how to do this in DAX (after several failed attempts, I am only able to return one value using lookup - not a list of values). An example of what I am trying to do, with SQL syntax, below:
Is it possible to write this lookup inside an 'IN' function using DAX? Am I going about this the wrong way?
Solved! Go to Solution.
Hi @Anonymous,
You can try to use below formula as filter condition:
[Region] IN CALCULATETABLE ( VALUES ( UserList[Region] ), FILTER ( ALL ( UserList ), [User email] = USERNAME () || [User email] = USERPRINCIPALNAME () ) )
BTW, I don't think you can directly use t-sql query in dax formula.
Regards,
Xiaoxin Sheng
Hi @Anonymous,
You can try to use below formula as filter condition:
[Region] IN CALCULATETABLE ( VALUES ( UserList[Region] ), FILTER ( ALL ( UserList ), [User email] = USERNAME () || [User email] = USERPRINCIPALNAME () ) )
BTW, I don't think you can directly use t-sql query in dax formula.
Regards,
Xiaoxin Sheng
Hi Xiaoxin,
This worked perfectly! Thank you!
A great solution to managing user roles using an external user-table managed by the business.
And -- you are of course right, t-sql doesn't work - I wrote it to provide an example of what I was trying to attempt in DAX.
Regards,
Oklande
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
User | Count |
---|---|
90 | |
89 | |
85 | |
73 | |
49 |
User | Count |
---|---|
167 | |
147 | |
92 | |
70 | |
58 |