Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Use UserprincipalName() in a Column . or a Measure

I have to build a link which includes the Employee Id of the Person logged in , but there is no relationship between the  Table that I am using and the staff table ... 

 

I have 2 columns in the table that have  link1 ( shows current data )  ,

       link 2  ( passing data from the table with adding the EmployeeId to the Link )  

 

No relationship between the Staff Table and the Data table to build the links 

 

Example 

 

Data Table 

   ID    Link1                                          Link2 

   1      http://mysite.mydata/1             Blank    

   0      Blank                                          http://mysite.newdata/new/Empidvalue

 

 

Staff Table 

   Empid       email 

   123           joe@mysite

   125           jane@mysite

 

I am using Row Level Security to limit the Staff table ... But confused on how to build the link with no relationships between the table 

 

Any help would be appreciated .... 

Kathy

5 Replies

  • negi007's avatar
    negi007
    Icon for Community Champion rankCommunity Champion

    Anonymous 

     

    You can put below condition in your RLS measure. It will search for the username in the staff table, if it finds it will result zero else -1 and then condition accordinlgy filter the data.

     

    INT(LOOKUPVALUE(Staff table[email],Staff table[email],USERPRINCIPALNAME(),-1))=0

    • Anonymous's avatar
      Anonymous
      Not applicable

      I can limit the staff table to the 1 row ... But I can not limit the other table ... there is no relationship @negi007

      • negi007's avatar
        negi007
        Icon for Community Champion rankCommunity Champion

        @kstachkunas in your data table, you can put below condition. It will search for the username in the userdetails table and if value is found it will return non blank values and blank value in case it is not found.

        negi007_0-1604412155160.png

        in below example, viewing using jane ID i am able to view the data

        negi007_1-1604412238923.png

        in below example, viewing using ID which does not exists in the able i am not able to view the data

        negi007_2-1604412274373.png

        If you wish to restrict view for multiple tables, you may have to use the same condition against each table. Pl. try this solution, it should work for you. Let me know if helps you.

  • v-alq-msft's avatar
    v-alq-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

    Data:

    Staff:

     

    You may create a new role as below.

    [Email]=userprincipalname()

     

     

    Then create a measure with following dax.

    Link2 Measure = 
    var c = 
    COUNTROWS(
        Staff
    )
    return
    IF(
        c>1,
        MAX(Data[Link2]),
        IF(
            MAX(Data[Link2])<>"",
            MAX(Data[Link2])&MAX(Staff[Email])
        )
    )

     

    Finally when you view as the corresponding role, it will display the result.

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • v-alq-msft's avatar
    v-alq-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous 

     

    If you take the answer of someone, please mark it as the solution to help the other member0s who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.

     

    Best Regards

    Allan