Row level security in Power Bi - powerbi

I am not able to implement row level security to my report. I have tried different methods on google and Microsoft forums but all in vain. Could you please help?
I have a dataset name "Cases" which have details of all cases logged into system with its country.
Then I have dataset name "Escalations" with details of the all the escalations along with its country.
Then there is one more table called "Country Mapping" which contains all the countries mapped with their Regions and Region Manager.
I have already prepared a report showing Global /Regional numbers But now people want to restrict the data according to its own territory.
Example :- Some want to see global data and some are responsible for a particular country. I know RLS can help me with this. I have tried to make two tables one with Username and country responsible and other one with just usernames and names.
I have made a relationship between all these tables. But the problem with the code is, like if I am the admin of the report then I need to manually add myself in the country responsible for every country. Like 146 countries .
Is there any better way to do this?

Related

PowerBI conditional/advanced filtering - is it possible?

I have a large set of Equipment data that contains both geographical equipment location and company ownership data.
The geographical data has a hierarchy based on size (i.e. continent, country, county, city, street), so the filters for that data is easy.
The company data details which companies own which pieces of equipment, but it’s not directly related to geography, so multiple companies can own equipment on a single site. So I can filter by company name nicely.
As the data is common to both company and location, I’d like to combine in to one dashboard, but with two filters. I’d love to be able to filter by location OR filter by Company but ideally, I don’t want the users to try to use both filters at the same time. Is it possible to have some logic built in so that if a user selects a location filter, it clears any Company filters selected and vice versa so that if a user selects a company filter any location filters already selected are cleared.
Is this possible and if so, how would I go about it?
Thanks in advance,
Dofus
Using buttons and bookmarks you can clear filters and toggle the visibility of slicers.

compare a measure to a value in a column

Power BI noob here, still thinking like a SQL coder, so please be patient.
How can I use the user name of the person running the report to filter the report?
As a convenience for my users, I want to provide a way for them to automatically filter to only see data related to their office or region. I have a Person table that includes details like their office location. If I can filter that based on the user name of the person running the report, and join it to the rest of the data, that would work.
Unfortunately, I don't see a way to get the user name in M.
Using the USERNAME() function in DAX, I don't see a way to compare this with individual values in a column. I get an error about being unable to compare a measure to multiple values.
It seems this would be a common request, so I'm sure somebody has solved this problem. But I haven't yet found the solution.
Use a RLS in your model. You can use function USERNAME(),USEROBJECTID (), USERPRINCIPALNAME (); The last one is useful if you have table with users and their email.
https://learn.microsoft.com/en-us/power-bi/admin/service-admin-rls
check also this GuyInCube video:
https://www.youtube.com/watch?v=MxU_FYSSnYU
First, be aware of the differences between USERNAME() and USERPRINCIPALNAME(). Most likely you will want to use the later one.
You can't use neither of these in M. Imagine your model is importing the data. The M code is executed once in the context of one user, then each other user accessing the published report will reuse the already loaded and calculated model. And of course, these are DAX functions, not M.
So in DAX you can use these to compare their values to columns from your model. You didn't gave any information about your model, but lets say there is a table Sales with columns Customer and Amount:
Customer
Amount
Bill Gates#Microsoft.local
100
Steve Ballmer#Microsoft.local
110
In this case, you can write a measure like this:
My Sales = CALCULATE(SUM('Sales'[Amount]), 'Sales'[Client] = USERPRINCIPALNAME())
When Bill Gates opens the report, he will see sales amount of 100, while if Steve Ballmer opens it he will see 110.
For diagnostic purpose, you can make a measure like this and show it somewhere in your report:
Who am I = USERPRINCIPALNAME()
If your goal is to build dynamic Row-Level Security within Power BI, it has some functionality which might help you, so take a look at these articles:
Row-level security (RLS) with Power BI
Restrict data access with row-level security (RLS) for Power BI Desktop
Row-level security (RLS) guidance in Power BI Desktop
Dynamic Row Level Security with Profiles and Users in Power BI : Many-to-Many Relationship

Role based security for tabs/pages in PowerBI (not row level secuity)

Is there a way to provide role based security for different tabs/pages on PowerBi cloud desktop version. As in, if I have a PowerBI report with 27 different tabs used by 4 departments, can we restrict access to each department based on tabs that is relevant to them. like maybe department 4 is only interested in tabs/pages 2,3,6,8 while department 2 is only interested in tabs/pages 2,7,8,11,21,23 so only those tabs from reports should be visible to them.
The challenge I faced in row level security- The whole framework/skeleton of report along with non-relevant calculations is visible to each user.
No, but this idea is submitted to Microsoft with a status "under review" and you may vote for it:
https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/16059178-page-tab-level-security

How to match a e-mail from a table with dax function USERPRINCIPALNAME and let the user visualize the report in PowerBI?

I need to hide a page from a group of users, but I've read that there is no RLS-like service to do that. I found a "tip" to use a card and paint it white or transparent to hide the page contents. It would work fine for me, but here is my problem:
I have a table with page name and the e-mail of the users allowed to access its contents. I need to query that table, returning the page name when the e-mail equals to USERPRINCIPALNAME (DAX function), but I haven't found how to link these information.
I tried to create a column named "allowed", comparing the e-mail value with this DAX function, but PowerBI does not allow its use (it can only be used with Measures). Then, I tried to create a measure comparing both values, but I cannot access the table value (it's not displayed in the list of available options).
What can I do? Any clues?
Regards
There is in fact RLS feature with Power BI that can be used to restrict data access for given users.
Refer: https://learn.microsoft.com/en-us/power-bi/service-admin-rls

Power BI reusign datasets

I have one dashboards one with all data from all countries, and I would like one single dashboard for each country reusing the previous dataset. I would like to do that to minimize the space needed in cloud for those dashboards. Also there is users that only should have access to data to each own country.
I tried to create a parameter to filter by country but it is not allowed when I reuse a data set as data source.
Could you please help me to find a way to reuse dataset filtering by country in order to minimize the resources needed?
Thanks in advance
Either use Row-level security to define which rows should be visible to the current user, or make separate reports for each country and share the data source between them. If you use Direct Query, there will be single copy of the data. Or you can publish one report with data for all countries to the cloud, and use it as a data source for the per-country reports.