Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register 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
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 64 | |
| 32 | |
| 31 | |
| 27 |