Forum Discussion
RLS problem with dynamic title for report
- 6 years agoHi there
What if you had to have the SELECTEDVALUE measure which would just use the default for example:
SELECTEDVALUE('Providers'[Provider],"All Providers") - 6 years ago
Hi Gilbert
Thank you that worked. A good example of occam's razor!
The reason my code did not work is the use of NOT ISFILTERED. I had assumed wrongly that the PBI service engine would apply a filter by Provider. Not so. The reason your solution works is because as we know SELCETEDVALUE is just syntax sugar for:
IF ( HASONEVALUE ( Table[column] ), VALUES ( Table[column] ), "default value" )So .
SELECTEDVALUE('Providers'[Provider],"All Providers")looks for one value, not to see if Provider is filtered.
Other replies to my post advising the use of USERPRINCIPLENAME() or USERNAME(), are wide of the mark because this approach only adds value if one wants to filter to an individual user. In my case I only need to filter RLS by an AAD security group, and the users within the relevant [Provider] AAD security group see only what RLS defines for that security group.
However, a Use case for a dynamic title for a user or all users would be SELECTEDVALUE([User],"All users")
where [User]. =USERPRINCIPALNAME() as long as the model is set up correctly.
Thanks again
Tony
It would depend on how you have configured your RLS.
If it is correctly applied I would expect the RLS to be applied no matter what the measure is being used?
Hi Gilbert
Thanks for getting back to me. I thought so too! RLS shows the correct content. Managemnet sees all the data (no Filters) and the title works dynamically and correctly. Providers see only their own data (filter by provider). It is only the title that does not work as I have described. As I have said it is because there is no default selection for no Provider. (.i.e. no filters are applied to the management Role.)
I can't see how to use Dynamic RLS in this situation because that would mean a many to many relationship of users sitting above Providers in the model. I would rather not use this approach because of the huge number of users.
Can IF then ELSE DAX be used in Role logic?
Thank you
- GilbertQ6 years agoSuper UserHi there
What if you had to have the SELECTEDVALUE measure which would just use the default for example:
SELECTEDVALUE('Providers'[Provider],"All Providers")- tonymaclaren6 years agoHelper I
Hi Gilbert
Thank you that worked. A good example of occam's razor!
The reason my code did not work is the use of NOT ISFILTERED. I had assumed wrongly that the PBI service engine would apply a filter by Provider. Not so. The reason your solution works is because as we know SELCETEDVALUE is just syntax sugar for:
IF ( HASONEVALUE ( Table[column] ), VALUES ( Table[column] ), "default value" )So .
SELECTEDVALUE('Providers'[Provider],"All Providers")looks for one value, not to see if Provider is filtered.
Other replies to my post advising the use of USERPRINCIPLENAME() or USERNAME(), are wide of the mark because this approach only adds value if one wants to filter to an individual user. In my case I only need to filter RLS by an AAD security group, and the users within the relevant [Provider] AAD security group see only what RLS defines for that security group.
However, a Use case for a dynamic title for a user or all users would be SELECTEDVALUE([User],"All users")
where [User]. =USERPRINCIPALNAME() as long as the model is set up correctly.
Thanks again
Tony
- GilbertQ6 years agoSuper UserThat is awesome, thanks for letting us know that it does indeed work!