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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

List of all entries in a Text column that contains a value present in the same column

USERGROUP URL
1ABC/DEF

1

PQR/STU

2

ABC/DEF/GHI/LMN

3

ABC/DEF/GHI

4

PQR/STU/VWX

5

MNO/CDE/TUV

 

So, if USER 1 has access to a path - ABC/DEF then he must have access to every group that falls under it as well. Hence, I want to find a way to display all the levels of access a user has by inheritance using Power Query.

Example, for User 1 here, the solution should be a list/record or just an indicator column that helps identify all the groups a user has access to - 

ABC/DEF, ABC/DEF/GHI, ABC/DEF/GHI/LMN, PQR/STU, PQR/STU/VWX

 

Please note that it has not been explicitly mentioned that User 1 has access to aforementioned sub-groups. 

1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

Hi @Anonymous ,
please find a possible solution in the file attached.
For performance reasons, the solution splits up the combinations value into rows and performs one merge before grouping things back together:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJ0ctZ3cXVTitWB8AMCg/SDQ0LBfCOEvL67h6e+j68fWNwYVRwsZoLQqx8WHgEWMwWK+fr56zu7uOqHhIYpxcYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [USER = _t, #"GROUP URL" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"USER", Int64.Type}, {"GROUP URL", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Duplicated Column" = Table.DuplicateColumn(#"Added Index", "GROUP URL", "GROUP URL - Copy"),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Duplicated Column", {{"GROUP URL - Copy", Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "GROUP URL - Copy"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"GROUP URL - Copy", type text}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type1", {"GROUP URL - Copy"}, #"Changed Type1", {"GROUP URL - Copy"}, "Matches", JoinKind.LeftOuter),
    #"Grouped Rows" = Table.Group(#"Merged Queries", {"USER"}, {{"Groups", each Table.Distinct(Table.Combine(_[Matches]), "GROUP URL")}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Text.Combine([Groups][GROUP URL], ", "))
in
    #"Added Custom"

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

1 REPLY 1
ImkeF
Super User
Super User

Hi @Anonymous ,
please find a possible solution in the file attached.
For performance reasons, the solution splits up the combinations value into rows and performs one merge before grouping things back together:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJ0ctZ3cXVTitWB8AMCg/SDQ0LBfCOEvL67h6e+j68fWNwYVRwsZoLQqx8WHgEWMwWK+fr56zu7uOqHhIYpxcYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [USER = _t, #"GROUP URL" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"USER", Int64.Type}, {"GROUP URL", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Duplicated Column" = Table.DuplicateColumn(#"Added Index", "GROUP URL", "GROUP URL - Copy"),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Duplicated Column", {{"GROUP URL - Copy", Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "GROUP URL - Copy"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"GROUP URL - Copy", type text}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type1", {"GROUP URL - Copy"}, #"Changed Type1", {"GROUP URL - Copy"}, "Matches", JoinKind.LeftOuter),
    #"Grouped Rows" = Table.Group(#"Merged Queries", {"USER"}, {{"Groups", each Table.Distinct(Table.Combine(_[Matches]), "GROUP URL")}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Text.Combine([Groups][GROUP URL], ", "))
in
    #"Added Custom"

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.