Narin
Narin

Reputation: 19

Display different columns in Power BI based on logged in user

I have a report on the power bi report server. There is a table visual inside this report. At work, my boss wants the salary and mobile number columns in this table visual inside the report to be visible only to 2 users. The rest of the users should see the values ​​in that column as 0. I want to do this. I created calculated column and measure using the following dax functions for .Then I tested what different users will see in Power BI Desktop using View as Roles Since BUT after saving and refreshing the report, all users saw that column as 0. However, users who have the privilige to see this column should have seen the data in this column I can't share the data here, I will show you an example that is very suitable for my work situation.

Suppose you have the following table of data, let’s call this table datatable:

name sensitive_value Alice Wonderlan 56 Bob Frost 32 John Doe 78 Mary Ann 36 Ted Smith 51

For privileged users, you would like to display the sensitive_value as-is in Power BI, while for non-privileged users, you would like to display the values as shown in the value column below

name             sensitive_value    value
Alice Wonderland                    0
Bob Frost        32                 0
John Doe         78                 0
Mary Ann         36                 0
Ted Smith        51                 0

I have tried this way to achieve this.

  1. I created calculated column for value column like this

Value=0

  1. Then I created table, called usertable, that contains the users who can see sensitive_value as-is:

    username [email protected] [email protected]

  2. Then I created measure to display either sensitive_value or value based on username() :

    display_value = var showvalue = IF(CONTAINS(usertable,usertable[username], USERNAME()), 1, 0) return if(showvalue = 1, max('datatable'[sensitive_value]), max('datatable'[value]))

  3. I tested with view as button for differenet users.I n the edit process everything is okey. But I save changes of this report .All users saw this column as 0 .

However some users(the users in the table I created for the following users) who have right to see the actual values ​​of the column

How can I handle this problem ?

Upvotes: 0

Views: 40

Answers (1)

Sam Nseir
Sam Nseir

Reputation: 12111

In Power BI Desktop, USERNAME() returns domain\username format, but when published it will change to UPN email address.

Suggest your switch to USERPRINCIPALNAME() which returns the same value in Desktop and Service.

Upvotes: 0

Related Questions