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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
v-binbinyu-msft
Community Support
Community Support

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
v-binbinyu-msft
Community Support
Community Support

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors