cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cbarriascb
New Member

User Privileges on Data

Hi Everybody!

I create a report that execute a database query: For Example table: "Sales". "Select user, date, usd from sales"

The report is a table that show all field of the query.

I have other table with the users and power bi account users: "Select user, pbiuser from users".

 

I need when the user A@onmicrosoft.com entry to the report, he only has access to his data. He can't see the other users data.

 

Is it possible to filter the data to show in the report, according to the logged in user?

 

Best regards,

----------------------------------------

Hola a todos!

Les cuento mi caso:

Genere un reporte que consulta una base de dato: Por ejemplo tabla "Sales". "Select user, date, usd from sales"

El reporte es una tabla que muestra todos los campos de la consulta.

Tengo otra tabla (Users) con los usuarios y su cuenta de power bi:

 

Quiero que cuando ingrese el usuario A@onmicrosoft.com, vea el reporte solo con los datos del usuario A.

 

¿Es posible realizar ese filtro?

¿Se puede realizar un filtro sobre los datos de acuerdo al usuario logueado que ejecuta el reporte?

 

Desde ya muchas gracias.

1 ACCEPTED SOLUTION
RicoZhou
Community Support
Community Support

Hi @cbarriascb 

From your statement, I think you want to restrict users to see the data by their account. You may want users can only see the data which they have access to.

Please try Dynamical RLS in Power BI to achieve your goal. Row-level security (RLS) with Power BI can be used to restrict data access for given users. Filters restrict data access at the row level, and you can define filters within roles. 

I build a sample to have a test.

Data Table:

1.png

User Table:

2.png

We need to build a relationship between ID columns(Key column) in two tables.

1.png

Then we find Manage Roles in Modeling ,build a new role and create Dax code.

1.png

Dax Code:

[ID] = 
CALCULATE (
    MAX(Data[ID]),
    FILTER (
        User,
        User[email] = USERPRINCIPALNAME()
            && User[ID] = Data[ID]
    )
) 

Let's have a test by View as function.

2.png

It works well. Then we can publish this report to Service. And we need to add users in Role in Dataset Security.

For more details: Manage security on your model

Users should only have view permission to dataset. If they have edit permission, RLS couldn't restrict them any more. 

For reference: Row-level security (RLS) with Power BI 

Dynamic Row Level Security with Power BI Made Simple

 

Best Regards,

Rico Zhou

 

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
RicoZhou
Community Support
Community Support

Hi @cbarriascb 

From your statement, I think you want to restrict users to see the data by their account. You may want users can only see the data which they have access to.

Please try Dynamical RLS in Power BI to achieve your goal. Row-level security (RLS) with Power BI can be used to restrict data access for given users. Filters restrict data access at the row level, and you can define filters within roles. 

I build a sample to have a test.

Data Table:

1.png

User Table:

2.png

We need to build a relationship between ID columns(Key column) in two tables.

1.png

Then we find Manage Roles in Modeling ,build a new role and create Dax code.

1.png

Dax Code:

[ID] = 
CALCULATE (
    MAX(Data[ID]),
    FILTER (
        User,
        User[email] = USERPRINCIPALNAME()
            && User[ID] = Data[ID]
    )
) 

Let's have a test by View as function.

2.png

It works well. Then we can publish this report to Service. And we need to add users in Role in Dataset Security.

For more details: Manage security on your model

Users should only have view permission to dataset. If they have edit permission, RLS couldn't restrict them any more. 

For reference: Row-level security (RLS) with Power BI 

Dynamic Row Level Security with Power BI Made Simple

 

Best Regards,

Rico Zhou

 

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

Thank you! it's works properly.

Hi!

Thank you.

I will test it and then comment if it works.

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Kudoed Authors