dynamic rls
18 TopicsDynamic RLS and using DirectQuery
speedramps again thank you very much for your help. Really appreciate your time and help for trying to solve this issue. I hope I've explained my issue as clear as possible. Goal Set up flexible (dynamic) Row-Level Security (RLS) in Power BI using a UserSecurity table that filters a FactTable. When a user logs in, the UserSecurity table should filter to that user, which in turn should filter the FactTable to only show data the user is allowed to see. Requirements All tables in the data model use DirectQuery. The UserSecurity table must support wildcards to indicate full access, in this case I use 0. The reaon for this is that I want to avoid that the table will get extremely large. Example: If a user has access to all ResourceGroups within a Subscription, the ResourceGroup field should be 0. A key use case to support is (please see attached Excel file (UserSecurity) for the full overview: User 16 has access to: All ResourceGroups in Subscription 17 Only ResourceGroup 15348 in Subscription 25 Limitations Because I’m using DirectQuery, I cannot use functions like CALCULATE or COUNTROWS in Manage Roles for RLS (they are disabled). If a relationship between the tables is needed, a many-to-many relationship is needed between UserSecurity and the FactTable because: Multiple users in UserSecurity Each user can have multiple different access rules (some full access via wildcard, some partial) However, many-to-many relationships are problematic with DirectQuery What I've Tried It works perfectly in Import Mode (use Test 1 as Role), but I must use DirectQuery. Please see attached PBI how it should work. I’m stuck translating the logic into a DAX approach that works in DirectQuery mode with these constraints. Ask How can I implement this kind of dynamic RLS with wildcard support in DirectQuery mode? I've attached 2 Excel files and a PowerBI file that can be used. Sorry, I don't know how to share a DirectQuery model because of privacy concerns. I hope this Excel files gives enough context. Link to download files: https://we.tl/t-PONAaflP8Q Many thanks again, and appreciate the help! Kind regards, NielsSolved2.9KViews0likes8CommentsDynamic RLS by using a UserSecurity table
Hi! In PowerBI, we have a data model and want to apply a quite flexible data security that includes all possible scenario's. To achieve this we are thinking about using a UserSecurity table, which has all the permissions per user. See below a short example of a scenario: _ID CLIENTID USERID SUBSCRIPTIONID RESOURCEGROUPID 201 3 16 25 15348 301 3 16 17 null In this case, user 16 can have access to subscription 25 but only to ResourceGroup 15348 within subscription 25. At the same time, user 16 can see everything in Subscription 17. We want to use null (wildcard) because otherwise the UserSecurityTable can get too large. I tried to use relationships to the dimension tables, but in the above mentioned scenario, the null value overrides it. Therefore, our idea now is to filter the fact table instead since all the id's are already in there (probably will get performance issues, but will solve that later). Further there won't be a relationship between the tables since we have to create multiple relationships between the 2 tables. So, we need a DAX query to solve this in Manage Roles but my DAX is so far not good enough to make it work. In SQL, we would use the following query to achieve this: from FactTable1 fact join UserSecurity usc on ( (fact.subscriptionid = usc.subscriptionid or usc.subscriptionid is null) and (fact.resourcegroupid = usc.resourcegroupid or usc.resourcegroupid is null) ) where usc.userid = 16 Could someone please help me with translating this SQL query to DAX? And I'm happy to receive some other idea's on how to set this data security up! Many thanks! Kind regards, NielsSolved1.5KViews0likes6CommentsDynamic RLS - DAX help needed
Hi! In PowerBI, we have a data model and want to apply a quite flexible data security that includes all possible scenario's. To achieve this we are thinking about using a UserSecurity table, which has all the permissions per user. See below a short example of a scenario: In this case, user 16 can have access to subscription 25 but only to ResourceGroup 15348 within subscription 25. At the same time, user 16 can see everything in Subscription 17. We want to use null (wildcard) because otherwise the UserSecurityTable can get too large. I tried to use relationships to the dimension tables, but in the above mentioned scenario, the null value overrides it. Therefore, our idea now is to filter the fact table instead since all the id's are already in there (probably will get performance issues, but will solve that later). Further there won't be a relationship between the tables since we have to create multiple relationships between the 2 tables. So, we need a DAX query to solve this in Manage Roles but my DAX is so far not good enough to make it work. In SQL, we would use the following query to achieve this: from FactTable1 fact join UserSecurity usc on ( (fact.subscriptionid = usc.subscriptionid or usc.subscriptionid is null) and (fact.resourcegroupid = usc.resourcegroupid or usc.resourcegroupid is null) ) where usc.userid = 16 Could someone please help me with translating this SQL query to DAX? And I'm happy to receive some other idea's on how to set this data security up! Many thanks! Kind regards, NielsSolved718Views0likes3CommentsSetting Default Value of Slicer Checkbox based on role/column?
Hello Team, Its a custom requirement for me, I have a table with ntid and appid with Table 1: ntid appid [email protected] 83 [email protected] 52 [email protected] 72 [email protected] 25 Table 2: I have a mapping table appid and its desctiption for above table. Also i have created a relationship for both the tables. Based on the image attached below while loading the page by default , based on the user([email protected]) logged into the system and the role management is configured properly and that specific users application assigned need to be selected in the slicer check box by default and all the other check box(other user application assigned names(id)) should show with out selected in the screen of slicer. How this is possible to make in Power bi? Thanks and Regards, SivaDynamic RLS with embedding
Hi, So I have embedded a powerbi report in another web application. To view the report, user needs to login. Now the report has data for all departments. But the logging in user belongs to some specific department and he should be given access to view only that data. Now the data part, The report contains 5 dashboard from 5 fact tables. All the fact table has department id which is mapped to a dim_department table (DIMENSION TABLE). Out of the 5 fact tables, we have fact_user table containing the username by which the user is logged in, his department ID and several other information which is required for dashboarding purpose. Tricky Part: There are around 30000 users logging into the web application from different domain without powerbi license. So we embed the report by Service principal (Azure Active Directory). How to apply RLS at department level in powerbi while embedding??Solved1.6KViews0likes4CommentsRLS based on 3 columns (All possible combinations)
Hi All, Looking to implement RLS that is based on 3 columns. So all possible combinations must be taken in to account while filtering. Consider the below table, the user could fall in either: - None of the columns, OR - Any 1 column, OR - Any 2 columns, OR - All 3 columns I am using an excel to capture the role against email IDs but can't crack the DAX yet in Manage Roles, any leads with the DAX will be really helpful.479Views0likes2CommentsDynamic RLS with Hierarchy for Embedded Paginated Reports in Power BI Desktop
Hello Power BI Community, I hope this message finds you well. I am reaching out to seek your expertise and guidance on a challenge I am currently facing with implementing dynamic Row-Level Security (RLS) with Organizational Hierarchy in an embedded paginated report. I have successfully implemented dynamic Hierarchy RLS for standard Power BI reports. The RLS is designed to allow Level 1 employees to view only their data, Level 2 employees to see their data as well as the data of all employees at Level 1 reporting to them, and so forth. While this dynamic Hierarchy RLS is working seamlessly for Power BI reports, I have encountered an issue with embedded paginated reports. Example, Level 1 employees can see not only their own data but also the data of their peers at the same level. I would greatly appreciate any guidance or assistance from the community on resolving this issue. If anyone has experience resolving such challenges with embedded paginated reports in Power BI Desktop, your insights would be invaluable. Any suggestions, best practices, or troubleshooting tips to ensure that the RLS filters out data accurately, maintaining the hierarchical structure for embedded paginated reports as well. Thank you in advance for your time and expertise. I look forward to your insights and suggestions.Solved983Views0likes3CommentsRLS DAX to provide dynamic BETWEEN where a user can have multiple rows
Hi, I'm trying to wrap my head around a complex RLS rule, where we need to filter the a column of a table to all the values between a start and an end point in the RLS table, however the complication is, a user can have multiple rows in the RLS table, and therefore multiple start and end values. The RLS table is in the strutcture below: username territory_code time_grain start_tgd_key end_tgd_key [email protected] AU Week 11200249 11299901 [email protected] AU Period 12200249 12299901 [email protected] AU Quarter 13200249 13299901 [email protected] IE Week 41200249 41299901 [email protected] IE Period 42200249 42299901 [email protected] IE Quarter 43200249 43299901 [email protected] NZ Week 91200849 91299901 [email protected] NZ Period 92200849 92299901 [email protected] NZ Quarter 93200849 93299901 [email protected] UK Week 111199801 111299901 [email protected] UK Period 112199801 112299901 [email protected] UK Quarter 113199801 113299901 And the table that the rule will be imposed upon like below: Stat_week territory_code time_grain tgd_key 199801 UK Week 111199801 199801 UK Period 112199801 199801 UK Quarter 113199801 200249 AU Week 11200249 200249 AU Period 12200249 200249 AU Quarter 13200249 200249 IE Week 41200249 200249 IE Period 42200249 200249 IE Quarter 43200249 200849 NZ Week 91200849 200849 NZ Period 92200849 200849 NZ Quarter 93200849 The rule needs to match the territory_code & time_grain values between tables, and then filter to all the values in tgd_key that are between the start_tgd_key and end_tgd_key. My starting point is the code below, which worked until we had to make it mulitple rows per user. VAR Start_filter = CALCULATETABLE ( VALUES ( 'rls account_calendar_meta'[start_tgd_key] ), 'rls account_calendar_meta'[username] = USERPRINCIPALNAME () ) VAR End_filter = CALCULATETABLE ( VALUES ( 'rls account_calendar_meta'[end_tgd_key] ), 'rls account_calendar_meta'[username] = USERPRINCIPALNAME () ) RETURN AND ( [tgd_key] >= Start_filter, [tgd_key] <= End_filter ) Grateful for any assistance that can be provided!! Thanks, MarkSolved515Views0likes2CommentsHelp on RLS in Power BI
Hi Team - We have tabular model (screenshot below) and enabled RLS on the "DimSubsidiary" table, which is applying security filter to the "FactSales" tables. However, we have a requirement to show sales different when slicer is placed on Geography. Example: As per Sample Data below, User A is allowed to see US and UK Subsidiary Data For User A: Total Sales (Subsidiary=US) = 100 + 600 ( Row 1 + Row 2) . This is working as expected. Total Sales (For Geo=US) = 100 ( because of RLS user A can see Row 1 and Row 2) and For US, it's 100. but User A has access to US subsidary , they should be able to see Revenue for US Geography i.e they should see sales as ( 100 (Row1) + 500 (Row 3) + 700 (Row 5) Beacuse of RLS in place this will not work Can you please suggest how to proceed further in order to show 1300 as sales for User A when we select Geo="US" ? Do I need to create any bridge table based of Fact? Data Model Thanks, Abhiram610Views0likes2CommentsOption to Disable/Bypass the RLS on active relationship
Hi Team - We have tabular model (screenshot below) and enabled RLS on the "DimCustomer" table, which is currently security applying the filter to both the "FactSales" and "FactCompute" tables. However, we have a requirement to disable RLS between the "DimCustomer" and "FactCompute" tables, while still keeping it enabled for the "FactSales" table. Upon reviewing the available solutions, I have come across below approaches, but it has certain disadvantages. Please suggest if there any other alternative options 1) Implement RLS on FactTable Implement RLS on FactSales Table Only Disadvantage: FactSales is very big , it occupies 70 GB in our data model. I think implementing RLS on Fact will slow down the performance. 2) Clone the Customer Table Have two set of Customer Table and enable RLS on One Customer Table. Disadvantage: If we want to show Sales and Cores by customerName in single chart then we will end up with customerName from different tables RLS Code On DimCustomer: VAR CUSTOMERS = CALCULATETABLE ( VALUES ( 'DimUser'[SubsidiaryID] ), 'DimUser'[UserAlias] = USERPRINCIPALNAME () ) RETURN 'DimCustomer'[CustomerID] IN CUSTOMERS Thanks, AbhiramSolved1KViews0likes1Comment