Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
SACooper
Helper II
Helper II

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 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @SACooper ,

My test table:

 

User_Mapping:

vbinbinyumsft_0-1659347569415.png

 

Product:

vbinbinyumsft_1-1659347592454.png

 

Mode:

vbinbinyumsft_2-1659347610567.png

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 ()
    )

 

 

 

vbinbinyumsft_3-1659347676020.png

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.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @SACooper ,

My test table:

 

User_Mapping:

vbinbinyumsft_0-1659347569415.png

 

Product:

vbinbinyumsft_1-1659347592454.png

 

Mode:

vbinbinyumsft_2-1659347610567.png

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 ()
    )

 

 

 

vbinbinyumsft_3-1659347676020.png

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.

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

Endurion
Helper I
Helper I

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).

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.