Forum Discussion

AlexGurovich's avatar
AlexGurovich
Icon for Helper II rankHelper II
5 years ago
Solved

Slicer Options depending on logged in User

Hi Everyone:
 
I would like a Slicer that I have in one of my pages to expose (or not expose)  products from the PRODUCTS Table based on the USER that is logged in from the Power BI service. So, for some USER, some subset of PRODUCTS should be exposed, and for some other USER another subset of PRODUCTS should be exposed.
 
How do I do that?  (NOTE:  I think RLS won't work for me, because RLS will expose (or not expose) those same PRODCUTS from all other visualizations (other graphics, charts, etc) , that shouldn't be impacted by who is the USER. )
 

 

 
 
  • Create a table (which will be hidden in the model) with pairs of (ProductID, Username). Username will be the user's email that they connect with, which you can return using a DAX function, probably Username() or something like this. This is the mapping you want to occur. Then connect Products via ProductID to this table with bi-dir filtering. Then put a slicer on the canvas as you would normally do using the column from Products. Then create a measure

     

    [ProductIsOKToShow] =
    var ProductIsOKToShow_ =
        NOT ISEMPTY(
            filter(
                ProductToUserBridgeTable,
                ProductToUserBridgeTable[UserName] = USERNAME()
            )
        )
    return
        1 * ProductIsOKToShow_

     

    and filter the slicer via Filter Pane where the condition [ProductIsOKToShow] is 1.

2 Replies

  • Create a table (which will be hidden in the model) with pairs of (ProductID, Username). Username will be the user's email that they connect with, which you can return using a DAX function, probably Username() or something like this. This is the mapping you want to occur. Then connect Products via ProductID to this table with bi-dir filtering. Then put a slicer on the canvas as you would normally do using the column from Products. Then create a measure

     

    [ProductIsOKToShow] =
    var ProductIsOKToShow_ =
        NOT ISEMPTY(
            filter(
                ProductToUserBridgeTable,
                ProductToUserBridgeTable[UserName] = USERNAME()
            )
        )
    return
        1 * ProductIsOKToShow_

     

    and filter the slicer via Filter Pane where the condition [ProductIsOKToShow] is 1.