Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi!
I'm kinda new to power query and I am struggling with something that maybe simple:
Giving this 2 tables:
UsersPermissions
User1 | 005 |
User2 | 010 |
PermisionsTablePath
005 | 005 |
010 | 005|010 |
020 | 005|010|020 |
I'd need to obtain this table in power query:
User1 | 005 |
User1 | 010 |
User1 | 020 |
User2 | 010 |
User2 | 020 |
How could I achieve this?
Thanks!
Solved! Go to Solution.
Based on the limited sample dataset,
let
PermissionPath = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjAwVdIBk7E6QJ6hAYRXA2KBRYyQRGpAvNhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Permission = _t, Path = _t]),
#"Sorted Rows" = Table.Sort(PermissionPath,{{"Path", Order.Ascending}}),
#"Transformed Path" = Table.TransformColumns(Table.RemoveColumns(#"Sorted Rows",{"Permission"}), {"Path", each Text.Split(_, "|")}),
UserPermission = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi1OLTJU0lEyMDBVitWB8I1AfEMDpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [User = _t, Permission = _t]),
#"Selected Path" = Table.TransformColumns(UserPermission, {"Permission", each let l=List.Last(List.Select(#"Transformed Path"[Path], (l) => List.Contains(l,_))), pos=List.PositionOf(l, _) in try List.RemoveRange(l, pos-1) otherwise l}),
#"Expanded Permission" = Table.ExpandListColumn(#"Selected Path", "Permission")
in
#"Expanded Permission"
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Thanks!!!
Based on the limited sample dataset,
let
PermissionPath = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjAwVdIBk7E6QJ6hAYRXA2KBRYyQRGpAvNhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Permission = _t, Path = _t]),
#"Sorted Rows" = Table.Sort(PermissionPath,{{"Path", Order.Ascending}}),
#"Transformed Path" = Table.TransformColumns(Table.RemoveColumns(#"Sorted Rows",{"Permission"}), {"Path", each Text.Split(_, "|")}),
UserPermission = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi1OLTJU0lEyMDBVitWB8I1AfEMDpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [User = _t, Permission = _t]),
#"Selected Path" = Table.TransformColumns(UserPermission, {"Permission", each let l=List.Last(List.Select(#"Transformed Path"[Path], (l) => List.Contains(l,_))), pos=List.PositionOf(l, _) in try List.RemoveRange(l, pos-1) otherwise l}),
#"Expanded Permission" = Table.ExpandListColumn(#"Selected Path", "Permission")
in
#"Expanded Permission"
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.