Forum Discussion

tonymaclaren's avatar
tonymaclaren
Helper I
6 years ago
Solved

RLS problem with dynamic title for report

I have RLS implemented and it works perfectly. However I have a dynamic report title that works based on the following measure: Selected Provider = IF( NOT ISFILTERED('Providers'[Provider]),"All P...
  • GilbertQ's avatar
    GilbertQ
    6 years ago
    Hi there

    What if you had to have the SELECTEDVALUE measure which would just use the default for example:

    SELECTEDVALUE('Providers'[Provider],"All Providers")
  • tonymaclaren's avatar
    tonymaclaren
    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