Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

RLS Question with Group

I am trying to use the RLS for a report and wanted guidance.    The report is to provide the details of the Spending amounts for the Sales Offices and the specific spending group.    The below ta...
  • nandukrishnavs's avatar
    nandukrishnavs
    5 years ago

    Anonymous 

     

    var _admin=DISTINCT('Admin'[Email])

    Getting the list of admin emails and assign it to _admin variable

     

    var _x = CALCULATETABLE(Division,Division[Email]=USERPRINCIPALNAME())

    Filtering the Division table based on login user and assign that into _x variable

     

    var _office = SELECTCOLUMNS(_x,"Office",[Sales Office])

    Creating a new table called _office. It will contain a single column "Office" which is derived from _x table. ie login user's office.

     

    var _group = SELECTCOLUMNS(_x,"Group",[Group])

    Creating a new table called _group. It will contain a single column "Group" which is derived from _x table. ie login user's group.

     

    var _OfficeManagerRole = AND([Sales Office] IN _office,[Spending Group]<>100)

    Specifying a filter condition, Office Manager Role

     

    var _ProdManagerRole = [Sales Office] IN _office

    Specifying a filter condition, Product Manager Role

     

    var _finalFilter =SWITCH(TRUE(), 
    USERPRINCIPALNAME() IN _admin, TRUE(),
    "Office Manager" IN _group, _OfficeManagerRole,
    "Prod Manager" IN _group, _ProdManagerRole)
    return _finalFilter

    Deciding the user role based on the login user.