Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Does anyone know if there's any way of treating DAX functions like mocked functions so they can spit out different values during testing? In particular it would be useful to specify the value returned by USERPRINCIPALNAME/USERNAME in desktop when you don't want to see 'your own' row limited set.
I'd imagine this would be a broadly useful feature, since USERPRINCIPALNAME is used in the overwhelming majority of RLS cases, and I would have thought it's quite a common scenario where a dataset developer doesn't exist in a business dataset (because they work in a separate function). When this happens the developer gets no rows back when ideally they would want to see a typical use case.
At the moment, the workaround is to comment out calls to the USERPRINCIPALNAME function and put a line below with a hard coded string. This isn't ideal given that the DAX editor in the manage roles dialogue isn't very good (can't indent, narrow space so you get a lot of visually confusing text wraps), and this could lead to testing code ending up in production.
Hi Stephen,
No, I'm looking to find a way of testing datasets by imitating a role member when the USERPRINCIPALNAME function is used in the RLS formula. Since USERPRINCIPALNAME only returns the current user we would need a way of mocking it so that the RLS 'view as' feature shows what a business user would see, when we as the developers don't exist in the dataset.
The only other options I can see are a) put dummy data into the dataset with the developer's username (not an option in all circumstances without changing the ingestion logic and risk putting that into production) or b) commenting out the call to USERPRINCIPALNAME as outlined in my OP, again risking that getting into production. Seems like there should be some way of achieving this, otherwise the 'view as' feature would be redundant in the majority of use cases.
Hi @JoshT ,
You want show the alternative value when there's no data because of RLS, right?
Please kindly refer to
Solved: alternative text to the visual object "Card" - Microsoft Power BI Community
Solved: Alternatives to RLS and dynamic RLS when there are... - Microsoft Power BI Community
Solved: Show text visual when user not in RLS - Microsoft Power BI Community
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
47 | |
22 | |
20 | |
15 | |
13 |
User | Count |
---|---|
49 | |
41 | |
39 | |
19 | |
19 |