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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
rode
Advocate II
Advocate II

Security role with more values

Hi everyone.

I'm getting in touch with the roles in Power BI. I've seen that there is a basic way to filter some tables basing on the username. Nevertheless, I've not found a simple pattern to address the need to filter out basing on many values. Let's see an example.

 

I have a fact table, called 'Fact', which is the one I want to filter out basing on some values. This table has field called Customer, which has values "A","B","C" and so on.

I've also created a table called 'Security' that has two fields: Username (which assumes the form ORGANIZATION\NAME) and SecCustomer. A user could be able to see more than one customer and for this reasone the table 'Security' contains many rows for each username in order to address this need.

 

I woul like to write a DAX formula in a role specificated for 'Fact' table that should have a behaviour like the following one:

[Customer] = LOOKUPVALUE('Security'[SecCustomer], 'Security'[Username], USERNAME())

The problem is that LOOKUPVALUE function returns only one value and does not suit at all this situation.

How can I do to filter out 'Fact' table basing on the Customers that come out from the security table in accordance to the given username?

 

Thanks.

1 ACCEPTED SOLUTION


@v-caliao-msft wrote:

Hi @rode,

 

You said that
"A user could be able to see more than one customer and for this reasone the table 'Security' contains many rows for each username in order to address this need."
Why not create a calculated column in Fact table
UserName = LOOKUPVALUE(Security[Username],Security[SecCustomer],'Fact'[Customer])

and then set role on Fact table.

 

Regards,

Charlie Liao


Hi @v-caliao-msft and thank you for your reply.

I have a fact table with too many rows and I think it's not a good solution for the performance perspective. However, this solution lets the user see the calculated column, and that's not so conceptually right sinche the fact this is a security information.

 

In any case, I've implemented a solution that suits well. Up to now I've ignored the context of roles, which is by row (please, correct me if I'm wrong). So, considering this, iht eonly thing to do is to write the DAX query in the role which will filter by Customer and by Username too, such that the lookup can return only one row:

NOT(ISBLANK(LOOKUPVALUE(
'Security'[SecCustomer],
'Security'[SecCustomer], 'Fact'[Customer],
'Security'[Username], USERNAME()
)))

 

View solution in original post

2 REPLIES 2
v-caliao-msft
Employee
Employee

Hi @rode,

 

You said that
"A user could be able to see more than one customer and for this reasone the table 'Security' contains many rows for each username in order to address this need."
Why not create a calculated column in Fact table
UserName = LOOKUPVALUE(Security[Username],Security[SecCustomer],'Fact'[Customer])

and then set role on Fact table.

 

Regards,

Charlie Liao


@v-caliao-msft wrote:

Hi @rode,

 

You said that
"A user could be able to see more than one customer and for this reasone the table 'Security' contains many rows for each username in order to address this need."
Why not create a calculated column in Fact table
UserName = LOOKUPVALUE(Security[Username],Security[SecCustomer],'Fact'[Customer])

and then set role on Fact table.

 

Regards,

Charlie Liao


Hi @v-caliao-msft and thank you for your reply.

I have a fact table with too many rows and I think it's not a good solution for the performance perspective. However, this solution lets the user see the calculated column, and that's not so conceptually right sinche the fact this is a security information.

 

In any case, I've implemented a solution that suits well. Up to now I've ignored the context of roles, which is by row (please, correct me if I'm wrong). So, considering this, iht eonly thing to do is to write the DAX query in the role which will filter by Customer and by Username too, such that the lookup can return only one row:

NOT(ISBLANK(LOOKUPVALUE(
'Security'[SecCustomer],
'Security'[SecCustomer], 'Fact'[Customer],
'Security'[Username], USERNAME()
)))

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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