Forum Discussion

SACooper's avatar
SACooper
Icon for Helper II rankHelper II
4 years ago
Solved

Dynamic Measure, show data based on usertpe

I have a user_mappings table which lists various different pieces of infomation about users of a system, such as AD loginname, email, userprinciplename (from ad), their manager, and if they are a manager themselves (1 for yes 0 for no).

 

What I am trying to do is within a measure workout if the user viewing the report is marked as a manager in the usermappings table if so show them a figure, and if not stay blank.

 

The idea being that a non-manager would see all the infomation about theselves shown in the report - and a blank column for this measure, whereas a manager would see the same info AS WELL as the infomation within the column.

 

I have the following

====

Manager? =
VAR _isManager = MAXX(
FILTER(
User_Mappings,
User_Mappings[ActiveDirectory.user.mail]=USERNAME()
)
,User_Mappings[IsManager_num]
)


RETURN IF(_isManager = 1, MAX('TABLENAME'[Booking]), BLANK())

====
 

I have created 3 temporary measures and thrown them on cards to verify that when I view the report as a known manager, I get the logged in user's email and UserPrinciplename correctly by the 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi SACooper ,

    My test table:

     

    User_Mapping:

     

    Product:

     

    Mode:

    Try below measure:

     

    Procuet_Fruit =
    VAR cur_email =
        SELECTEDVALUE ( User_Mapping[Email] )
    VAR cur_isManager =
        SELECTEDVALUE ( User_Mapping[IsManager_num] )
    VAR cur_upn =
        USERPRINCIPALNAME ()
    RETURN
        IF (
            cur_email = cur_upn
                && cur_isManager = 1,
            CALCULATE (
                MAX ( 'Product'[Fruit] ),
                FILTER ( 'Product', 'Product'[Email] = cur_email )
            ),
            BLANK ()
        )
    

     

     

     

    Best regards,
    Community Support Team_ Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

     

    My question is how large this organization is and how other managers change. If this is a manageable size is would make two Row-Level-Security roles that filter on different aspects of the windows AD. The nice part of this is that if a user is a manager and become a non-manager he/she would see nothing anymore as a safequard of GDPR (Europe).

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi SACooper ,

    My test table:

     

    User_Mapping:

     

    Product:

     

    Mode:

    Try below measure:

     

    Procuet_Fruit =
    VAR cur_email =
        SELECTEDVALUE ( User_Mapping[Email] )
    VAR cur_isManager =
        SELECTEDVALUE ( User_Mapping[IsManager_num] )
    VAR cur_upn =
        USERPRINCIPALNAME ()
    RETURN
        IF (
            cur_email = cur_upn
                && cur_isManager = 1,
            CALCULATE (
                MAX ( 'Product'[Fruit] ),
                FILTER ( 'Product', 'Product'[Email] = cur_email )
            ),
            BLANK ()
        )
    

     

     

     

    Best regards,
    Community Support Team_ Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • SACooper's avatar
      SACooper
      Icon for Helper II rankHelper II

      This is brilliant thank you - think  got myself working down the wrong route here but with a little tweak, this worked!