HomeVideos

Power BI Security Complete Guide: RLS, OLS & TMDL (Manual + AI Methods)

Now Playing

Power BI Security Complete Guide: RLS, OLS & TMDL (Manual + AI Methods)

Transcript

1158 segments

0:00

Hello everyone. Welcome back to

0:01

Analytical Guy. In this video, we will

0:03

talk about a very important topic in

0:05

Power BI, that is security. So, if

0:07

you're creating reports and you're

0:10

publishing it and sharing with multiple

0:12

users, it is important for us to

0:14

understand how the data is being used.

0:16

Is it exposed to everyone? Do you want

0:18

to expose all the elements, whatever is

0:20

there in your semantic model, to

0:22

everyone? So, if the answer is no, then

0:24

you have to create a security layer. And

0:27

in security, we talk about RLS that is

0:30

row level security. Second is OLS, which

0:32

is object level security. So, there are

0:34

two ways and I will explain you both of

0:37

them in this particular video. Once this

0:40

manual setup is done, then I'll also

0:42

explain you how to utilize AI to do all

0:45

the security part for you. So, let's get

0:47

started. All right. So, let's start with

0:50

both the concepts. What is RLS and what

0:53

is OLS? Just briefly and then I'll

0:55

explain you in depth. So, first of all,

0:58

RLS is row level security. OLS is object

1:02

level security. So, you will use RLS

1:05

whenever you want to control which rows

1:07

a user can see. For example, if you have

1:09

this data, this is a dimension customers

1:12

table. You have all the customers over

1:15

here. So, you can see customer key, then

1:16

we have gender, then we have the

1:18

customer name, we have state, zip code,

1:21

country, continent, and birthday. For

1:25

example, now you want to create a

1:27

filter. For example, you have various

1:30

store managers and store managers are

1:32

maybe on the base of continent. So, you

1:34

want to have a user who can see only the

1:37

data which is related to Australia, only

1:40

the Australia customers. So, you have to

1:43

apply row level security. And now you

1:46

can apply same with Europe and same with

1:48

North America. Right? So, row level

1:51

security is straightforward. You You are

1:53

essentially filtering out the rows of a

1:56

particular table. Right? So, that's what

1:59

RLS means. Second is OLS, which is

2:01

object level security. In object, that

2:04

means it can control columns or tables

2:07

or both. Right? So, for example, you

2:10

feel birthday column is sensitive and

2:12

you don't want to showcase the age of a

2:15

customer to your store managers. So, you

2:18

can hide essentially this particular

2:20

column

2:21

with all the users. So, you can create a

2:23

separate role which hides a particular

2:26

column and then whenever you give that

2:28

permission, give that role to a

2:30

particular user, that particular user

2:32

won't be able to see this column and

2:34

would be able to see everything else.

2:36

Right? So, we will see we will

2:37

demonstrate everything on Power BI to

2:40

understand how it's done. All right. So,

2:42

before we go ahead, let me tell you what

2:44

all is covered in this video so that you

2:45

know what is coming next. So, first of

2:49

all, we'll talk about how to implement

2:51

row level security. So, there are

2:53

multiple methods I'll talk you walk you

2:55

through all of them. Then how to

2:57

implement OLS, that is object level

2:58

security. So, there are two ways, Tim

3:01

Dale method and tabular editor method.

3:03

So, we will demonstrate both of them.

3:05

Once these two setups are done, we will

3:08

talk about the challenges with these

3:10

manual methods and then we will talk

3:12

about how to utilize AI to overcome

3:15

these challenges. And finally, the key

3:17

takeaways and best practices when we are

3:19

talking about securities in Power BI.

3:21

All right. So, let's start with row

3:23

level security, that is RLS.

3:26

In manual setup,

3:27

before we deep dive, let me give you

3:30

quick glance of RLS. So, first is it

3:32

filters the data based on the user

3:34

context. That's what we discussed. If

3:36

you want to filter particular records,

3:37

you can filter that.

3:39

User see the same report but different

3:41

data. So, you have different users, they

3:43

will see the different data but the same

3:45

report. The report name and everything

3:46

will remain the same.

3:48

It uses the DAX logic plus lookup value.

3:50

We will demonstrate that in the setup.

3:53

And it is applied at the query time.

3:55

This is important. So, we will talk

3:57

about when OLS is applied, but this RLS

4:00

is applied at the query time. So, once

4:02

the query runs, it is applied at that

4:05

particular time. It is perfect for

4:06

regional organizational hierarchy. So,

4:08

if you have regional hierarchies and

4:10

then you can easily apply RLS.

4:13

All right. So, let's deep dive into the

4:16

setup. All right. So, to understand RLS,

4:18

we will talk about two methods. One is

4:21

static RLS. In this, we will talk about

4:23

how to create one role per store. So,

4:26

it's like if you have 100 stores, you

4:28

have to create 100 roles. So, one role

4:30

per store. This is quite challenging

4:32

because if you have multiple stores, if

4:34

it is growing, then you have to create

4:37

the roles again and again. Second method

4:39

is dynamic and that is better than what

4:42

we are going to do in this one. So, for

4:44

this one, let's go straight to Power BI

4:46

desktop and I'll explain you how it's

4:48

done. All right. So, now we are on Power

4:50

BI desktop file and before we start, let

4:53

me just show you the data set. So, we

4:56

have dimension customers, then we have

4:58

dimension date, dimension product. So,

5:01

if you see on the right-hand side, so we

5:03

have dimension customer, dimension date,

5:05

dimension products, dimension stores,

5:08

and then fact sales. So, you don't need

5:10

to worry about these two as of now. So,

5:12

currently we have four dimension tables

5:13

and one fact table. And if you go in

5:17

your modeling, you will see

5:20

there are four dimension tables and one

5:23

fact tables. And this is how you work

5:25

one-to-many relationship. Right? So, now

5:28

we have this and let me show you the

5:30

columns in dimension customers because

5:32

we are going to utilize this even more.

5:35

So, you will see customer key. For each

5:37

key, we have the gender, customer name,

5:39

city, state code, state, zip code,

5:42

country, continent, birthday column, and

5:45

then customer key name. All right. So,

5:47

now that we know the columns inside each

5:50

table, let's understand how to implement

5:53

row level security. Method number one is

5:56

static. All right. For that, first of

5:58

all, you will go to the modeling tab.

6:02

So, once you click on modeling, then you

6:04

will see manage roles. So, once you

6:07

click on manage roles, you just need to

6:10

create a new role from here. So, you can

6:12

see the for you, once you open your

6:14

file, it will show you as empty. This

6:17

will be empty. There won't be any role.

6:19

These are the roles which I created.

6:21

Right? So, now you have to click on the

6:24

new button. So, once you click on new,

6:27

and it will click as an untitled. So,

6:30

you can mention it as, let's say, row

6:33

level security for

6:37

Western Australia.

6:39

Right? So, now I have created row level

6:41

security for Western Australia. So, what

6:43

I want,

6:45

if I go to a particular dim stores,

6:48

and so, there are two options. So, one

6:51

is a blank where you can just click on

6:53

the plus new icon and it will show you

6:55

all the columns and you can apply rules.

6:57

Or there is second option is switching

6:59

to DAX editor and you can

7:01

write your DAX query and it will work.

7:03

Right? So, for now, this is static and

7:05

it is straightforward. In dim stores,

7:08

I'll click on new and my WA Western

7:11

Australia is state. So, I'll just click

7:13

on state and it should be equal to

7:15

Western

7:16

Australia.

7:19

This is manual straightforward. So, what

7:21

it does is whenever the state is Western

7:23

Australia Australia, this will show only

7:25

those records. Click on save. And once

7:28

you click on save, it should show you

7:30

successfully applied rule changes. That

7:32

means the rule is correct and now you

7:34

can close this.

7:36

just see over here.

7:39

For example, you will see continent

7:41

Australia, Europe, North America. And

7:43

for Australia, you can see quantity is

7:45

3576. Right? And we have all the data

7:49

right now. But now, if I have to test if

7:51

my role has been created successfully,

7:53

on the top, I can click on view as. So,

7:56

if I click on view as and go to RLS_WA,

8:01

which is the row level security for

8:04

Western Australia only, then click on

8:06

okay.

8:08

Right? So, now you will see over here

8:10

everything changes. This will only show

8:12

for Australia and that to Western

8:14

Australia. So, remember, this is only

8:16

for Australia and quantity was somewhere

8:19

around 3,000, now it is 730 only. So,

8:21

all the details, everything is shown for

8:24

Western Australia. And now, to confirm

8:27

this, you can go to data set. And if I

8:29

go to dim stores, you will see only this

8:33

particular record. So, we had multiple

8:37

records, but now it will only show you

8:39

for state Western Australia. So, this is

8:41

how you can test and see if the role has

8:44

been created successfully or not. And

8:45

once it's done, you can click on this

8:47

stop viewing, so it will stop and it

8:49

will go back to the original one.

8:52

Simple. Right? So, this is a static RLS.

8:54

So, just imagine if I go back here and

8:57

in dim stores, you will see now all the

8:59

states are coming in. Right? So, now

9:01

imagine if you want to create

9:04

a role for each state. So, right now we

9:06

have somewhere around 60 plus states

9:08

over here. So, if you

9:11

create a role for each state, you will

9:13

have to do this 60 times. And this is

9:15

time consuming and this is not a best

9:17

practice. Right? So, if you have if you

9:19

are a small team and just two or three

9:21

users, this is good enough. But if

9:25

there is a scale, you're scaling and you

9:27

have multiple users using this kind of

9:30

report, then comes the second option,

9:33

which is dynamic RLS. All right. So, now

9:35

coming to method two, which is dynamic

9:37

RLS, which is more flexible and

9:39

scalable. So, if you have hundreds or

9:42

thousands of users and they have

9:44

different roles, you can create one role

9:46

for all. And then

9:48

you need a mapping table for this. So,

9:50

this is one extra step in setup, but it

9:53

is very straightforward. So, So, you

9:55

need is one role and mapping table.

9:57

That's all, right? And finally, this is

10:00

how your Tim Dale script will look like.

10:03

I will show you for method one as well.

10:05

So, this is a script that will come in.

10:07

So, it shows that what has been done.

10:10

For example, over here you will see one

10:12

role store manager has been created. It

10:14

says model permission is read. So,

10:16

that's good. So, what it does is for all

10:18

dim stores,

10:20

store key looks up into the mapping

10:22

table and it maps with the store key.

10:25

And finally, it gives you the manager

10:28

email ID for that particular store key.

10:30

And then, if you are logged in up with a

10:32

particular email ID, it will map

10:35

with this particular manager ID and it

10:36

if it is matches, then you will see all

10:38

the data for that particular

10:40

store key. Otherwise, you won't. So,

10:42

this is where we use user principal

10:45

name. And this is important in this

10:47

part. All right. So, in order to

10:49

implement the dynamic role level

10:51

security in Power BI, step number one is

10:53

to create the mapping table. So, now

10:56

that you know that for each store key,

10:58

you need to have a email ID which has to

11:00

be associated with the user. So, if I

11:03

log in with that user

11:05

email ID, I should be able to see those

11:07

particular store keys, right? So, if I

11:09

have that mapping table, then I can

11:12

easily create a DAX and then it will

11:14

seamlessly work dynamically. So, step

11:16

number one, creating the

11:18

table. So, currently I have created a

11:20

demo

11:21

small mapping table over here you can

11:24

see. So, I have store keys 1 2 3 4 5 6

11:28

and manager email ID. So, if you see

11:31

over here in dim stores, we have store

11:32

key from 1 going till 66, right? So, we

11:37

have a total 66 stores over here.

11:40

But, I have only created just for six

11:44

just for demonstration purpose. So, now

11:46

I have store key one associated with

11:48

manager email admin@analytical-guy.tech

11:51

and then all those dummy email IDs and

11:54

then just for testing purpose, I have

11:56

created store key six which is

11:59

atikant@analytical-guy.tech.

12:01

So, we will test with this email ID so

12:03

as to see if it is working or not. All

12:05

right. So, once you create this table

12:07

and if you are thinking how to create,

12:10

you can create an Excel and then import

12:12

this or if it is just five or six, you

12:15

can just click on enter data from top

12:17

and then enter all your records and then

12:20

it's created. So, essentially, you need

12:22

to create a table over here. You can go

12:24

in Power Query which is a better way

12:26

or using data flows. So, once it's done,

12:29

so you have this mapping table. So, once

12:31

you have mapping table, map this column

12:33

with dimension stores store key, right?

12:36

So, if I go to the model view and see on

12:39

the left hand side, so you will see

12:42

dimension stores this

12:44

one is connected to

12:46

roles mapping table, right? So, connect

12:49

currently it is many to many, but you

12:51

can make it one to many.

12:53

Generally, it is better, but it's fine.

12:55

But, the arrow should be from

12:59

roles mapping table to

13:01

dim stores. All right. So, now that we

13:03

have this relationship done,

13:06

the third step is to create the DAX.

13:09

Right? For DAX, I'll go to report view,

13:12

click on

13:15

Right? So, once you click on modeling,

13:16

then click on manage roles. So, once you

13:19

click on manage roles, click on the new

13:22

roles and here I'll create

13:26

store manager demo.

13:29

Right? So, in store manager demo, I will

13:33

click in

13:34

dim stores. So, I'll click here.

13:37

Right? So, once you click on dim stores,

13:39

click on switch to DAX editor. And over

13:42

here, you have to write your DAX. So,

13:45

just for simplicity, I'll go to my

13:48

existing store manager and this is what

13:50

we want to create. So, I'll just copy

13:51

this and go to store manager demo which

13:54

we created just now. I'll paste this.

13:56

Let me explain you now what this is

13:58

doing. So, what I'm saying is

14:00

in dim stores, we have a column name

14:02

store key. In my instance, my store key

14:06

was

14:07

six and the manager email ID was

14:11

atikant@analytical-guy.

14:14

tech. So, what I'm saying is so,

14:17

whenever the manager email ID is equal

14:18

to user principal name. So, if I log in

14:20

with my email ID in Power BI services,

14:23

if I log in with this, so according to

14:26

this rule, it will match this email ID

14:29

with this manager email ID for store key

14:32

is equal to six. So, that means so,

14:34

whenever it is matching, it will return

14:37

my store key which is equal to six. So,

14:39

that means in dim stores, it will filter

14:41

for store key is equal to six.

14:43

Otherwise, every other store key is

14:45

filtered out. I won't be able to see any

14:46

other store key, right? So, that's the

14:48

logic.

14:49

So, if I remove this and click on save,

14:52

it should give me successfully applied

14:55

and that's good. So, once this is done,

14:57

I'll click on close and I can easily

15:00

test over here. In modeling, go to view

15:03

as, click over here,

15:05

click on store manager demo. If I click

15:09

on okay, this will give you everything

15:12

blank because it is not able to

15:15

understand which user you're going for.

15:17

There are so many users in store manager

15:19

demo, right? So, I can click on stop

15:21

viewing, click on view as again,

15:24

go to store manager demo. But, in other

15:27

users, this is where I have to mention

15:29

my name. So, atikant@analytical-guy.tech

15:32

analytical-guy

15:36

.tech. So, once I click on okay, I

15:39

should be able to see the data only for

15:41

store key is equal to six.

15:44

So, once I click on okay, I'll see the

15:46

data only for store key is equal to six.

15:48

So, if if I add store key over here from

15:52

dim stores,

15:55

so you will see it is just six, right?

15:58

In visualization, let me add in the

16:00

right way

16:01

and you will see this is only

16:03

demonstrating the data for six. And six

16:06

means Western Australia in this

16:07

particular data set. And you will see in

16:09

dim store, everything else is filtered

16:11

out. I won't be able to see anything

16:12

else. This proves that my role level

16:15

security is working. And the best part

16:18

is

16:19

you can create this online. So, once you

16:22

publish this,

16:24

click on save and let me test this on

16:27

services as well. Right? So, I'll just

16:29

look for my security

16:32

workshop.

16:35

Replace.

16:38

So, once it's published, let me open

16:40

this. So, once you have published the

16:42

report, you will see a semantic model

16:45

over here. So, this is semantic model

16:47

and you will see semantic model has six

16:49

dots like this icon. And once you see

16:51

semantic model, click on three dots,

16:53

click on security.

16:55

So, once you click on security, you have

16:58

all these options, role level security

17:00

options.

17:01

AJ Birthday, AJ Birthday one. These are

17:03

all test roles which were created

17:06

earlier. So, this is the one we created

17:08

now, store manager demo. Right? And the

17:11

best part is you can click on three dots

17:14

and click on test as role and you can

17:15

test if it is working or not. So, this

17:18

is essentially a place where you need to

17:21

add different users. If there is a new

17:22

user user and you want to add the other

17:25

role

17:27

the user in that particular role. For

17:29

example, you have RLSWA. So, there is a

17:33

new user and you need to give him access

17:35

to just Western Australia.

17:37

Right? So, add that particular user in

17:40

this one. So, if you click on this one,

17:42

go to this one and add that particular

17:45

email ID. All done. And once you add,

17:48

don't forget to click on save because

17:50

sometimes people don't save it and feel

17:51

like they have already added that

17:53

particular member in RLS.

17:55

All right. So, now this is a complete

17:57

setup for role level security. All

18:00

right. So, in role level security, I

18:01

just want to show you one more thing.

18:03

So, if you click on the TMDL icon on the

18:06

left hand side, click on Tim Dale and

18:09

over here on the right hand side, you

18:11

will see the semantic model.

18:13

Under semantic model, you have options

18:15

like cultures, then measures,

18:18

expressions, functions, everything. Then

18:20

you will see roles as an option, right?

18:23

So, this is what we are looking for. So,

18:25

if you expand roles, you will see a

18:28

particular role that we created just now

18:30

which is store manager demo, right? So,

18:33

if you select store manager demo, just

18:36

drag this one over here.

18:39

Anyway, so we can drag in the new one to

18:42

make it easier.

18:44

All right. So, this is the one we

18:47

created, right? So, this is the script

18:49

we created using

18:51

the

18:52

manager roles, right? So, once you

18:55

create, it will go in the semantic model

18:57

and this is how it is captured. So, what

18:59

it's saying is create or replace. So, we

19:02

are creating this role. So, if it was

19:03

already there, it will replace. So, we

19:06

are creating store manager demo. The

19:08

model permission is read. So, on the

19:10

table, so there is another

19:13

parameter that is table permission. So,

19:15

in table permission, we are saying in

19:17

the table dim stores, this logic should

19:20

be applied.

19:21

So, store key should be equal to the

19:23

store key of mapping table and on the

19:26

basis of whenever the manager email is

19:28

equal to the

19:30

user principal name. So, once this is

19:32

done and this will stay in your

19:35

file. So,

19:37

so whenever you download this as PBIP

19:39

and you will see this semantic model

19:41

comes in. That's also the reason when we

19:44

connect with the cloud, you connect with

19:45

PBIP and it has all the semantic model.

19:48

So, this Tim Dale is always there. So,

19:51

it has the complete context of your

19:53

semantic model.

19:54

>> [snorts]

19:55

>> All right. Same with the any other one.

19:57

So, if you create any other role, you

19:59

can see how it's done over here. If you

20:01

are liking this video so far, I would

20:03

really appreciate if you can subscribe,

20:05

like, and comment on this video, and

20:07

this will help me to create even more.

20:09

All right. So, coming back, so real

20:11

scenario, understanding how these uh RLS

20:16

works. For example,

20:19

So, let's compare static versus dynamic.

20:23

First example is

20:25

user Atikant moves from store 6 to 5.

20:28

So, if this is the scenario, what will

20:31

happen if you are using static roles?

20:33

Step one is you have to remove user

20:35

Atikant from store 6 role, then you have

20:37

to add Atikant in store 5 role. Step

20:40

three would be once this is done, you

20:42

have to publish the changes, then you

20:43

have to refresh the data set, then you

20:45

have to notify Atikant as a user. Once

20:47

it's done, this will take you 25 to 30

20:50

minutes, and this is just for one user.

20:53

Right? Method two, dynamic RLS. In this

20:57

one, what you have to do is just go to

20:59

your mapping table, update uh the user

21:03

Atikant. So, it is mapped to six, just

21:05

change it to five. That's it. So, once

21:08

this is done, just refresh your data

21:09

set, it's all done.

21:11

The user will automatically see the new

21:13

store. So, that's the beauty of working

21:15

on dynamic RLS. And once you have this,

21:18

you just need to update your mapping

21:20

table whenever there are multiple

21:22

changes in your users, they are shifting

21:24

from one store to another, or new users

21:26

are coming in. And this will literally

21:28

take you less than 5 minutes. So, this

21:30

is the shift. And this is what makes

21:33

dynamic RLS really good. All right. So,

21:36

now let's talk about the second scenario

21:38

where the dynamic roles

21:40

make it even better. So, if you have to

21:42

add new store

21:44

100 in

21:46

Bali, for example. So, in static roles,

21:50

first of all, you have to create a new

21:51

role, the way we created for WA, right?

21:54

So, you'll create something like store

21:56

{underscore} 100 {underscore} Bali.

21:58

Then you will write a DAX filter, or you

22:00

will apply whenever the state is equal

22:02

to Bali or whatever the name is. Then

22:05

you will publish to service, then you

22:07

will map that particular email ID to

22:10

this particular user role, and then you

22:12

have to test and validate. Definitely,

22:13

it will take 50 to 60 minutes. Right?

22:16

Whereas dynamic RLS is so good, you just

22:18

need to add one more row in that mapping

22:21

table. So, you will understand that

22:23

dynamic RLS is so good that you just

22:24

need to work on your mapping table, and

22:26

that's it. So, add a new role where

22:28

store key is equal to 100, and email ID

22:30

is the one that you want to give the

22:33

access to.

22:34

Once this is done, that's it. You just

22:35

need to refresh, and it's done.

22:38

The user will automatically has the

22:39

access. This will take less than 5

22:41

minutes. You can see the difference. So,

22:43

this is where dynamic RLS is really

22:46

nice. All right. So, now we are done

22:48

with row-level security, let's start

22:50

with object-level security, and this is

22:53

very interesting as well.

22:55

All right. First of all, quick glance.

22:57

So, we have already talked about what is

22:59

OLS. So, it hides columns as well as

23:02

tables from the users. So, in case you

23:04

want to hide, for example, birthday

23:05

column from the table dim customers,

23:08

then you can easily hide that, and user

23:10

won't be able to see those sensitive

23:11

data. So, in case you have finance data,

23:14

and you want to hide salaries from the

23:18

other employees, so you can easily work

23:20

on object-level security, and it's all

23:22

done. So, in fact, data is not filtered

23:25

over here. It is redacted. So, in it's

23:28

not like we are filtering the data set,

23:30

and you're able to see the less records.

23:33

You would be able to see all the

23:34

records, but less of the columns.

23:37

Users see the same structure, but

23:39

sensitive columns don't appear.

23:41

>> [snorts]

23:41

>> No DAX is needed, applied before query

23:44

execution. Now you understand, so when

23:46

we talk about row-level security, it is

23:48

applied at the time of query execution.

23:51

All right. So, let's talk about the

23:52

method number one to implement

23:54

object-level security. Method one is

23:56

using the external tool, that is Tabular

23:59

Editor. So, if you have worked on Power

24:01

BI since long, you must be aware of this

24:03

particular tool. If not, I'll just tell

24:05

you how to install it. It's very

24:07

straightforward.

24:10

So, once you install, I'll explain you.

24:12

This is the interface part. So, if you

24:14

see over here, you will see this is the

24:17

menu icon, and then on the left-hand

24:19

side, we have the model, whatever the

24:22

data is there, we will see the roles as

24:24

well, all the tables, translations. And

24:26

once you have selected a particular

24:27

object in this model, it will translate

24:30

and show you all the

24:32

metadata over here. Right? So, this is

24:35

how the structure looks like in Tabular

24:36

Editor. So, first of all, let me show

24:38

you how Tabular Editor is installed in

24:41

Power BI, and then we'll see how we can

24:43

uh define OLS inside Tabular Editor. All

24:47

right. So, now we are on Tabular Editor

24:49

website. So, if you go over here, you

24:51

will have this option, downloading

24:53

Tabular Editor three. So, my suggestion,

24:56

don't go for Tabular Editor three, that

24:58

is a paid version. So, if you click on

25:00

this arrow, downward arrow, click on

25:03

there, go to Tabular Editor two, which

25:05

is open source. Once you click on

25:07

Tabular Editor two open source, you can

25:09

just click here, and it will download.

25:11

So, once you download, it is

25:13

straightforward the way you install any

25:15

other software. So, once it's installed,

25:17

it will straightaway come in your Power

25:19

BI app.

25:20

All right. So, now if I open my Power BI

25:23

and go back to the report view, and just

25:27

need to click on the external tools over

25:30

here.

25:31

So, if you click on external tools, you

25:33

will see the

25:34

Tabular Editor Editor shown over here.

25:37

All right. So, now in

25:40

order to create OLS, so first of all,

25:42

I'll go to modeling.

25:44

Right? So, click on modeling, click on

25:46

manager roles. Once I have clicked on

25:49

manager roles, I'll click on new, and

25:51

let's say I want to create object-level

25:54

security on birthday.

25:57

Right? So, I'll just mention OLS

25:59

{underscore} birthday. Right? So, I've

26:01

created this OLS {underscore} birthday.

26:03

You don't need to worry about anything

26:05

else, just click on save from here.

26:08

So, that means this has already applied

26:11

successfully. So, we have created this

26:12

role, but there is no rule for this, so

26:15

it won't work for now, but we have this

26:18

rule.

26:19

Right? So, now once you have created

26:21

this role, click on external tools,

26:24

click on Tabular Editor. So, once you

26:26

have clicked on Tabular Editor,

26:29

there will be a new window popped up,

26:31

and this is Tabular Editor. On the

26:34

left-hand side, you will see roles, you

26:36

will expand that. So, once you expand

26:38

this, you will look for the role that

26:41

you created just now, which is OLS

26:43

{underscore} birthday. Right? So, if you

26:45

click on OLS {underscore} birthday, you

26:47

will see the new information coming in

26:49

over here. You will see metadata, then

26:51

you have annotations, then you have

26:53

securities. So, this is what we are

26:55

looking for. So, if you go to security,

26:58

you have row-level security. We don't

27:00

need to worry about row-level security,

27:01

we are looking for object-level

27:03

security, that is table permission. So,

27:05

you will expand this, and in customers,

27:08

currently it's default, so I want to

27:11

have

27:17

dim customers as none.

27:20

Right? So, this will ensure, or I can do

27:23

this as read, so the user can read this

27:26

particular table, but now inside this

27:29

particular table, I will create a

27:32

particular rule. So, once I have done

27:34

this none, so you will see on the

27:35

left-hand side,

27:37

this dim customers has been created. So,

27:39

if you click on here, again on the

27:42

right-hand side in the window, you will

27:44

have

27:44

this one.

27:47

Security OLS column permissions. So,

27:49

this is what we are looking for. In

27:50

columns, in birthday, currently it's

27:52

default, so make it none.

27:54

So, once you have created none, so that

27:56

means this particular role can see

28:01

all the objects over here. For example,

28:04

in table, you will see all the objects,

28:06

and dim customer is on read, while in

28:09

dim customers,

28:13

if you go further in the columns,

28:15

everything is default, so I would be

28:17

able to see everything for this

28:18

particular role, except birthday column,

28:20

which is none. So, once you are done

28:22

with this, click on save on

28:25

this icon. So, once you click on save,

28:28

this is saved. You can close this one,

28:30

and you can go to modeling, and click on

28:36

view as. So, if you click on view as,

28:39

and look for object-level security

28:42

{underscore} birthday. So, once you

28:44

click on this, click on okay.

28:46

So, see, if you see over here,

28:49

this visual is

28:52

giving me errors, because this had

28:55

If you click on this visual, this had a

28:58

particular column, which was birthday.

29:00

So, I won't be able to see over here,

29:02

because this is hidden by default.

29:04

Right? So, if I go to stop viewing, it

29:07

will go back come back again, and this

29:09

was over here, you can see in values.

29:13

Right? So, if I go to view again, sorry,

29:15

modeling again, click on view as, and

29:18

click on

29:20

object-level [snorts]

29:21

security {underscore} birthday. So, now

29:23

it is hidden, and now let me see this

29:25

confirmation in the data set. So, if I

29:28

go to dim date, everything is showing

29:29

up, dim products, everything is showing

29:31

up, dim stores, everything is showing

29:33

up. Now, if you go to dim customers,

29:35

everything is showing up. Just it won't

29:37

show you birthday. And this is some

29:40

somehow not showing you up, but state,

29:43

zip code, everything should be shown.

29:45

You can see everything is shown. If you

29:47

click on birthday, nothing will be

29:48

shown. You will see it is all blank.

29:51

So, this shows that you can apply object

29:55

level security, and this way you won't

29:58

be able to expose what is what should

30:01

not be exposed to the regular users.

30:04

Right? And now you can confirm this over

30:06

here as well. So, if I just remove this,

30:09

go to rules, and I can also search OLS_

30:13

birthday, and drag this over here. So,

30:16

what it does is it gives you read

30:18

permission, and then again we have table

30:20

permission, we have column permissions.

30:22

In table permissions, it says

30:24

for dim customers, read option, that's

30:27

great. So, I can read the table. In

30:29

column permission for birthday, it is

30:31

none.

30:31

Right? So, I cannot read uh I cannot see

30:35

this particular column. Same, if I have

30:37

multiple columns, I can just add uh more

30:40

columns here equal to none, and it will

30:42

not show in my data set. That's how you

30:45

can uh save, or you can say have

30:48

sensitive data, still it won't be

30:50

exposed to the desired users.

30:53

Right? So, this is method one on how to

30:55

apply object level security. All right.

30:58

So, let's talk about the method two for

31:01

applying OLS, that is Tim Dale.

31:04

Tim Dale is TMDL, that is tabular model

31:07

definition language, and this is where

31:10

you create some scripts, and this goes

31:12

in semantic model, and is understood by

31:15

the complete model. So, what it does is

31:17

first of all, you have to write create

31:19

or replace, and then create a rule, and

31:21

what is the name of that particular

31:22

rule, then what is the model permission,

31:25

then what is the table permission, and

31:26

what is the column permission, and

31:28

that's how you can create the Tim Dale.

31:30

So, let's go ahead, and let's try to

31:32

create this. All right. So, now that we

31:34

are on Power BI desktop file, and I have

31:38

opened the Tim Dale tab. So, in Tim

31:40

Dale, currently there is the role

31:42

OLS_birthday that we created earlier.

31:45

So, in this one, I'll just create using

31:47

this, I'll create a new role. For

31:49

example, for object level security,

31:52

birthday_ let's say continent.

31:55

So, what I'm saying is

31:58

or you can say birthday_gender.

32:01

So, this role,

32:04

what I want is I want

32:06

allow particular users to see the

32:08

birthday as well as gender of a

32:09

particular customer. [clears throat]

32:11

Right? So, the model permission will say

32:13

remains same, that is read. Table

32:15

permission, this is the dim customers

32:17

read, that's good. In column permission,

32:20

birthday is equal to none, that's great.

32:21

I'll just add one more column permission

32:25

for gender

32:28

equal to none.

32:30

Right?

32:32

And that's it. So, you you can remove

32:35

this annotation because this is already

32:37

done, or you can change the annotation

32:39

PVI ID, and that will work. So, once

32:41

this is done, click on apply.

32:45

Uh you will exit the current view,

32:46

that's fine.

32:48

And now you'll see

32:50

changes applied to the model. Right? So,

32:53

this particular role,

32:54

OLS_birthday_gender,

32:57

I won't be able to see birthday as well

32:58

as gender. Right? So, if I want to test

33:01

this, I'll go here in modeling, click on

33:04

view as, and go to

33:08

OLS_birthday_gender,

33:10

click on okay.

33:12

So, see this has been hidden, that's

33:13

good. And now if I go to my table view

33:18

in dim customers,

33:21

I should not be able to see gender.

33:23

Currently shown because it takes the

33:25

default state, but now if I click on

33:27

here, it won't show you. Right? So, if I

33:29

go here, it will show you everything. If

33:31

I go back to dim products, it will show

33:33

you everything. Come back to dim

33:34

customers, now gender is gone. Right?

33:38

Under gender, you will see this. So,

33:40

gender column is hidden anyways, and

33:42

same with birthday. So, you will see

33:45

birthday as a header, but it won't show

33:47

you the values underneath.

33:50

Right? So, this is the beauty of how we

33:52

can apply the permissions, object level

33:55

security, and you can

33:58

uh literally define which user users can

34:01

see what data

34:03

and schema. Right? So, this is the

34:05

beauty of OLS. So, same goes So, for

34:08

example, if you don't want So, let's

34:10

create a new one. So, I don't want this

34:13

particular user to see customer table

34:16

itself.

34:17

So, I'm applying role OLS_customer

34:20

table. So, I'm saying table permission

34:22

dim customers, for this one, it should

34:24

be none.

34:26

And I can remove other two columns.

34:30

Right? So, if I apply this,

34:33

you will exit, that's okay, and it will

34:35

say changes applied to the model. So,

34:38

for this role, I'll copy this, I'll go

34:40

here back to view as again, and I'll

34:44

look for

34:46

OLS_customer

34:47

table,

34:48

and click on okay. So, this will hide

34:51

these two visuals because we don't have

34:53

customer table anymore. So, if I go

34:56

here, and click on anywhere else, dim

34:59

data, dim products, and now if I click

35:01

on dim customers,

35:03

I should not be able to see that. So,

35:06

that's

35:08

strange. Let me see what's happening.

35:13

Yes. So, you don't see over here.

35:16

So, this is already loaded data, so

35:19

that's shown. But if I expand, if I

35:21

click on customer key, it is all

35:24

blank. If I click on gender, it is all

35:28

blank. Right? So, once you're done with

35:30

this, and you will refresh, publish it

35:32

in the services, then users won't be

35:35

able to see even this data. Right?

35:38

So, this is how you can apply the rules.

35:41

So, you can create rules through TMDL

35:44

scripts as well, and this is

35:46

straightforward. All right. So, now we

35:48

understand what is RLS, what is OLS, and

35:51

how to set up and do all the securities

35:55

in Power BI. But, why to do manually in

35:58

this AI era? Right? So, in this one, in

36:00

this section, we will talk about how you

36:02

can utilize AI to create these

36:04

securities in Power BI.

36:08

So, first of all, what AI can do in in

36:12

regards of Power BI security? So, first

36:14

of all, it can generate 50 row level

36:16

securities with just one prompt. So, for

36:19

example, if you have to do static RLS,

36:22

one RLS will take you 5-6 minutes,

36:24

right? And there are 50, that can take

36:26

you 2-3 hours, right? But, if you're

36:29

generating through Claude or any other

36:31

AI, and uh if you're

36:34

uh you have uh structured it very well,

36:36

it will take you less than 10 minutes,

36:37

and it's all done. Same with if you want

36:40

to generate the Tim Dale OLS for all the

36:43

customer for all the columns, the way we

36:45

did for dim customers, you can do this,

36:47

and it will take you literally 5

36:48

minutes. You can audit, you can fix all

36:51

your broken Tim Dale scripts using

36:54

Claude, and it will identify, it will

36:56

show you what are the errors, and then

36:58

you can fix it. Or you can connect

36:59

directly with MCP the way I did in the

37:01

last videos, and it will automatically

37:03

change in your semantic model.

37:05

Same, generate validation checklist. So,

37:07

there is a validation checklist when

37:09

you're talking about security. So, you

37:10

can see what are the checklist, and you

37:13

can test and do everything by yourself.

37:17

So, essentially, you're spending 20-30

37:20

minutes instead of 4-6 hours, this is

37:22

80% faster. So, when we talk about how

37:25

AI can be utilized by Power BI

37:27

developers, this is what we're talking

37:29

about. We still need to know the

37:31

concepts. You can't just rely on Claude

37:34

or any other AI tool that tell me how to

37:37

create RLS, OLS, what is RLS,

37:39

etc., etc. You need to know the concepts

37:42

that will help you

37:43

optimize it faster, and this is what the

37:46

people are looking for, make it fast.

37:48

All right. So, let's see some examples

37:50

on how AI can be utilized for this.

37:53

First of all, easy demo, I'll talk about

37:56

the easy prompting. If you have to

37:57

generate DAX, so you can just give this

38:00

prompt.

38:03

And then, it will give you this script,

38:06

and you don't need to know DAX for this,

38:08

for example. So, essentially, what we

38:10

want is we want to create RLS DAX rules

38:13

for three continents, for example,

38:14

Australia, Europe, and North America.

38:17

Uh you need to filter dimension

38:18

customers continent column based on the

38:20

logged in user email ID. So, for

38:23

example, if I'm logged in, I should be

38:24

only able to see data related to

38:27

Australia. I should not be able to see

38:28

data for Europe and North America. So,

38:31

you will use lookup value to match users

38:33

to dimension customer continent. Right?

38:35

So, this is the script.

38:39

The script is dim stores region is equal

38:41

to lookup value, dim users region, and

38:44

whenever the email of dim users equal to

38:46

user principal name, give me this

38:47

region, and this maps, and then it will

38:49

give me the desired output only. And

38:52

this is easy, I mean, straightforward,

38:53

so you can use Claude or any other AI

38:56

for this. All right. So, demo two, this

38:57

is again very easy prompting. So, if you

39:00

need to generate the Tim Dale script, so

39:02

the input is if you want to hide columns

39:04

from intern user role and external

39:07

partners, so you will say dim customers

39:09

birthday, and dim finance cost, margin,

39:12

all these columns should be hidden. So,

39:14

generate Tim Dale with permissions is

39:15

equal to none. So, it will give you the

39:17

role intern_access, model permission is

39:20

equal to read, table permission for dim

39:22

customers, column permissions birthday

39:24

is equal to none, and etc. So, this is

39:26

what we demonstrated, we created

39:28

ourselves, but if you uh want Claude to

39:31

be useful in these regards, just have a

39:33

good prompt, and it will do it for you.

39:35

Some of the other interesting use cases

39:38

of using AI for Power BI securities is

39:42

when we have dynamic hierarchical

39:44

security. For example, if you have

39:45

organization plus geography plus

39:48

exceptions, how to

39:50

tackle with this issue? The problem is

39:52

users belong to region, country, and

39:55

store, right? So, some users will see

39:57

entire region, others will only be able

39:59

to see the specific stores, some would

40:01

have some exceptions like extra access

40:03

and all. So, for this, you need to have

40:06

a more complex DAX. Right? So, for

40:10

example, the DAX will look like this.

40:12

So, if I'm saying the user principal

40:14

name is in values of security email,

40:16

calculate true filter the dimension

40:19

store where the region is in values of

40:21

securities and store keys in the values

40:23

of security store key. Right? So, if

40:25

this is true, then it will map. So, this

40:28

is what AI can help you with. Otherwise,

40:30

you have to write I mean, it's not

40:32

time-consuming if you know, but if you

40:34

don't know, then you can utilize Claude

40:36

for this. So, it's like generating

40:37

multi-layer row-level security logic. It

40:39

handles hierarchies, overrides, and

40:43

if there are edge cases, it will take

40:44

care of it. Similarly, there is one more

40:46

use case working on multi-role conflict

40:49

resolution. So, if you have multiple

40:51

roles like admin, manager, auditor,

40:53

which is generally the use case. So, the

40:56

problem is users belong to multiple

40:58

roles, admin which has full access,

41:00

manager will have limited, and auditor

41:02

will only have read-only subset. Right?

41:04

So, Power BI behavior will be like union

41:06

of all the rows roles, which can cause

41:09

overexposure. And this is what happens

41:11

if we have one particular user in

41:13

multiple roles, there will be some

41:15

conflict.

41:17

So, it will detect security leaks,

41:19

and it will suggest how to design. And

41:21

this is what we can create. So, we can

41:23

create a DAX which is like switching.

41:25

Whenever the role is admin, makes it

41:27

make it true, that means it's there. If

41:29

it is manager, then work on this

41:31

particular condition. If it is auditor,

41:33

then work on this condition. Right? So,

41:35

this is how we can utilize AI to make it

41:38

faster and optimized in terms of

41:41

security. All right. So, there are many

41:43

more ways of how AI can be utilized for

41:46

this particular

41:47

problem, but one most important thing is

41:50

documenting. So, if you want to document

41:52

your security architecture, it is very

41:54

useful. So, I've already created this

41:56

particular document in Notion. I'll just

41:58

open that. So, what it does is So, this

42:00

is the prompt which I created over here.

42:02

So, this is like creating a professional

42:04

well-structured PDF document for Power

42:06

BI security implementation. Document

42:09

should write a clear consulting style

42:11

format suitable for businesses. It It

42:14

should have executive summary. This

42:15

should explain

42:17

the purpose of document, importance of

42:18

data security using RLS and OLS. So, you

42:21

have to mention how many stores are

42:22

there in this particular continent,

42:24

role-based columns restrictions. What is

42:26

the architecture overview? This is

42:28

important. Then, what is your RLS

42:30

implementation in this particular Power

42:32

BI

42:33

project? What is the OLS implementation?

42:35

Then, the mapping table design. So, if

42:38

there is a new person coming in your

42:40

team, he should know what's happening

42:41

inside and how to

42:44

continue from there. And then,

42:46

deployment checklist and testing phase

42:48

and finally auditing and best practices.

42:50

So, I've already created this prompt.

42:52

I'll just copy this prompt in Claude or

42:54

ChatGPT, it will give me the document.

42:56

So, this is how the document looks like.

42:59

This is the PDF, and it is a four-page

43:02

PDF. And then, of course, you can modify

43:04

the the prompt and the way you want, and

43:08

it will show you that. So, it will show

43:10

you executive summary that is there,

43:12

then architecture overview,

43:14

then RLS implementation, OLS

43:16

implementation. It will show you the

43:18

mapping table. Then, it will also show

43:19

you the deployment checklist, audit

43:22

trail template, how it's done, and

43:24

finally the best practices and to be

43:26

taken care of for this particular

43:28

project. So, this is important in terms

43:30

of documenting whenever there is a large

43:33

team and you want to

43:35

do knowledge transfer and new person is

43:37

coming in, this is very useful. All

43:39

right. So, I'll just conclude this video

43:41

with some key takeaways. First of all,

43:43

RLS is row-level security. It filters

43:46

rows based on the user context. OLS, it

43:49

hides columns or tables from users. One

43:53

user is equal to one role, multiple

43:55

roles is unpredictable. So, that's what

43:58

I was saying. If you have multiple

43:59

users, so for example, if one user is in

44:01

multiple roles, that will give you some

44:04

conflict. So, we should not have that.

44:06

Always test on Power BI service. So,

44:08

whenever you're testing on desktop,

44:10

sometimes there's a caching problem or

44:12

something, then generally it might

44:15

give you wrong answers, but always test

44:18

on

44:19

Power BI services. So, once you are on

44:21

Power BI services, go to security and go

44:24

to all the roles and click on test as

44:26

role, and that should give you the best

44:28

answer.

44:30

Claude saves 80 to 90% of your time. So,

44:32

whenever I work on these aspects, I try

44:34

to utilize all of the AI tools and see

44:37

if

44:38

that is helping me reduce the time of

44:40

preparation. Right? Using Tim Bill for

44:43

complex OLS setups. This is really nice.

44:45

And documenting your security

44:47

architecture. This is what I explained

44:49

previously. And validate quarterly. So,

44:51

it is important for us to

44:53

check them regularly so as to see if

44:56

there are some changes and you want to

44:57

modify any business requirement changed,

45:00

then you need to modify all those

45:01

things. So, this is what this video was

45:04

for. If you like such videos, please

45:06

like, subscribe, and help me grow on

45:09

this channel. Thanks a lot for watching

45:10

this video.

Interactive Summary

This video provides a comprehensive guide to implementing data security in Power BI, covering both Row-Level Security (RLS) and Object-Level Security (OLS). The tutorial demonstrates manual setup methods, such as using DAX for dynamic RLS and the Tabular Editor for OLS, while also highlighting the benefits of utilizing AI tools like Claude to automate script generation, optimize security configurations, and document the architecture, ultimately saving significant development time.

Suggested questions

3 ready-made prompts