+ Reply to Thread
Results 1 to 11 of 11

Populating a matrix permissions hierarchy based on parent values

  1. #1
    Registered User
    Join Date
    12-01-2019
    Location
    USA
    MS-Off Ver
    365
    Posts
    21

    Populating a matrix permissions hierarchy based on parent values

    Greetings all,

    I'm trying to populate implicit values in a hierarchy, but haven't had much luck.

    This is my input sheet ("Input Matrix"):

    01.png

    I want to create an output sheet ("Output Matrix") that looks at the values in column D and fills in any missing:

    02.png

    Some context: this is a menu permissions hierarchy for a product that assumes all menu items are enabled unless explicitly disabled. The product is capable of storing a Y/N permission for every menu item at every level, but is often configured such that only a parent menu item is disabled; child items are implicitly disabled, but not explicitly. The objective is to pull table data for explicitly-disabled menu items and determine the full implicit security matrix.

    The logic for column D in Output Matrix could be something like this:

    Please Login or Register  to view this content.
    This matrix will have a maximum of 7 layers, 50 users, and 1000 rows. Ideally the solution would not require VBA, unless this is required to keep performance at a reasonable level.

    The first challenge to me is the "find parent" portion; I'm unsure how to "look up" from my starting cell to find the location of the first non-blank value in the adjacent column. Any suggestions much appreciated.
    Attached Files Attached Files
    Last edited by alexdi; 01-18-2020 at 06:14 PM.

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,557

    Re: Populating a matrix permissions hierarchy based on parent values

    Hello alexdi and Welcome to Excel Forum.
    This proposal employs a number of helper columns which may be moved and/or hidden for aesthetic purposes. The helper columns (E:I) are populated using relatively simple formulas so, hopefully, they will not produce a performance issue for a machine capable of running the 365 version of Excel.
    Column E finds the layer and is populated using: =SUMPRODUCT((A2:C2<>"")*COLUMN(A2:C2))
    Column F identifies the parent row and is populated using: =IF(E2=1,"",AGGREGATE(14,6,ROW(A$1:A1)/(E$1:E1<E2),1))
    Column G returns permissions for layer 1 along with those explicitly stated and is populated using: =IF(D2<>"",D2,IF(E2=1,"Y",""))
    Columns H:I (and presumably through M) returns the permissions of succeeding layers and is populated using: =IF(G2<>"",G2,INDEX(G$2:G$12,$F2-1))
    Note that the values in column I match those in column D on the output matrix sheet.
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  3. #3
    Registered User
    Join Date
    12-01-2019
    Location
    USA
    MS-Off Ver
    365
    Posts
    21

    Re: Populating a matrix permissions hierarchy based on parent values

    Thank you, that solution is clever and functional for the example sheet. I used a similar mechanism elsewhere in a related sheet. Unfortunately I'm not able to adapt it here because scaling it to the full sheet becomes unwieldy. That sheet currently has 7 layers and 30 users. Because the helper columns except for Layer and Parent Row are specific to each user, I think I would need about 212 of them.

    Do you know if there is a way to do this in one column, or with helper columns that are not user-specific?
    Last edited by alexdi; 01-02-2020 at 11:34 AM.

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,557

    Re: Populating a matrix permissions hierarchy based on parent values

    I am not sure that I understand the difference that "users" make. Could you update the file attached to post #1 so that we can see how having two users would change the expected outcome?
    Let us know if you have any questions.

  5. #5
    Registered User
    Join Date
    12-01-2019
    Location
    USA
    MS-Off Ver
    365
    Posts
    21

    Re: Populating a matrix permissions hierarchy based on parent values

    Sure, let me attach it here.

    I did actually implement the solution, but it's not really maintainable and quite slow to update. This is the helper column set for the real sheet:

    excel1.png

    The first 30 columns are just copies of every L7 column for convenience. The full set of helper columns extends to IH.

    In the sheet attached, I showed what this looks like for two users. There are 30 now and potentially a few more in the future.
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,557

    Re: Populating a matrix permissions hierarchy based on parent values

    See if the following would work:
    1. On the Input Matrix sheet cell H4 has data validation applied so as to choose the user from the User Input sheet
    2. Cells H5:H19 are populated using: =IF(INDEX('User Input'!A2:B2,MATCH(H$4,'User Input'!A$1:B$1,0))=0,"",INDEX('User Input'!A2:B2,MATCH(H$4,'User Input'!A$1:B$1,0)))
    Let us know if you have any questions.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    12-01-2019
    Location
    USA
    MS-Off Ver
    365
    Posts
    21

    Re: Populating a matrix permissions hierarchy based on parent values

    Sorry, I think my example was misleading. The goal is do this without helper columns. I can hide them in various ways, but it makes the sheet very difficult to update and maintain.

    Better example attached.
    Attached Files Attached Files

  8. #8
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Populating a matrix permissions hierarchy based on parent values

    populating-a-matrix-permissions-hierarchy-based-on-parent-values-implicitpermissionstest_update.xlsx

    Without helper columns, there is a bit going on. But try in Column K of the input tab use in Row 5

    =IF(H5<>"",H5,IF(LOOKUP(2,1/($A5:$G5<>""),COLUMN($A5:$G5))=1,"Y",INDEX(K4:K$5,MATCH(LOOKUP(2,1/(INDEX($A$4:$G5,,LOOKUP(2,1/($A5:$G5<>""),COLUMN($A5:$G5))-1)<>""),INDEX($A$4:$G5,,LOOKUP(2,1/($A5:$G5<>""),COLUMN($A5:$G5))-1)),INDEX($A4:$G$5,,LOOKUP(2,1/($A5:$G5<>""),COLUMN($A5:$G5))-1),0))))


    Copy down and across

    populating-a-matrix-permissions-hierarchy-based-on-parent-values-implicitpermissionstest_update.xlsx

    This works when the immediately preceding sub-layer is a unique value in that layer. If not, there needs to be an array formula which is a whole new level of complexity
    Last edited by Ace_XL; 01-16-2020 at 01:55 PM. Reason: Typo
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  9. #9
    Registered User
    Join Date
    12-01-2019
    Location
    USA
    MS-Off Ver
    365
    Posts
    21

    Re: Populating a matrix permissions hierarchy based on parent values

    In implementing this, I have an unrelated issue: the actual sheet is offset by a column (i.e., the relevant range to review is B:H, the check column is K, and the result column is AP). Fixing the check and result columns works, but when I try to modify the check range, the formula breaks. Excel reports circular references. I've been poking at it for an hour now and can't figure out why it's breaking. Any thoughts?
    Last edited by alexdi; 01-16-2020 at 03:25 PM.

  10. #10
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,557

    Re: Populating a matrix permissions hierarchy based on parent values

    Assuming that when the offset is taken into account "User 1 Output" is in cell L4, Try pasting the following into cell L5 and then copy down and over:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.

  11. #11
    Registered User
    Join Date
    12-01-2019
    Location
    USA
    MS-Off Ver
    365
    Posts
    21

    Re: Populating a matrix permissions hierarchy based on parent values

    You're a wizard, that works well! I ended up adding a salt to my values so they'd always be unique. If you have a moment, can you explain at a high level what the logic is doing? (Or if there's a good tool to reverse-engineer it?)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Finding parent in a hierarchy
    By Mackay2m in forum Excel General
    Replies: 12
    Last Post: 11-20-2019, 01:54 AM
  2. [SOLVED] Organizational hierarchy from parent
    By Imbizile in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-30-2018, 02:58 AM
  3. Replies: 1
    Last Post: 06-05-2018, 02:35 PM
  4. Average value of a parent in an hierarchy
    By nik.rao in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-08-2018, 01:01 AM
  5. Replies: 4
    Last Post: 05-19-2015, 11:53 PM
  6. Summing matrix values based on X & Y axis values
    By vtbigmac in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-24-2009, 01:29 PM
  7. [SOLVED] populating sheets based on data from parent sheets
    By seve in forum Excel General
    Replies: 3
    Last Post: 01-15-2005, 06:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1