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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Gurps
Frequent Visitor

How to extract each value from a range into a separate table?

I have one table, let's call it "User Dimension Values"  that has the following layout:

Gurps_0-1690364816141.png

 

User IDDimensionDimension Values
User ADimension A100..208
User BDimension A100..202|204..205

 

This is linked with another table, let's call it "Dimension Table" which will have the following layout:

Gurps_0-1690364851877.png

 

Dimension CodeCode
Dimension A050
Dimension A100
Dimension A201
Dimension A202
Dimension A203
Dimension A204
Dimension A205
Dimension A208

 

I want to use Power Query to create a third table inside Power Bi which would then have the following format:

Gurps_1-1690364936778.png

 

 

User IDDimensionCode
User ADimension A100
User A Dimension A201
User A Dimension A202
User A Dimension A203
User A Dimension A204
User A Dimension A205
User A Dimension A208
User B Dimension A100
User B Dimension A201
User B Dimension A202
User B Dimension A204
User B Dimension A205

 

So how do I take the values in the "Dimension Values" column from the "User Dimension Values" Table and use the ranges such as 

  • 100..208
  • 100..202|204..205

To then produce a table that will show me row by row each dimension value assigned to each user from the range?

 

Thanks

 

 

 

1 ACCEPTED SOLUTION
slorin
Super User
Super User

More simple

let
Source = #"User Dimension Values",
List = Table.AddColumn(Source, "Dimension Values 2", each Expression.Evaluate("{" & Text.Replace([Dimension Values], "|", "} & {") & "}")),
Expand = Table.ExpandListColumn(List, "Dimension Values 2"),
Join_Inner = Table.NestedJoin(Expand, {"Dimension", "Dimension Values 2"}, #"Dimension Table", {"Dimension Code", "Code"}, "Dimension Table", JoinKind.Inner)
in
Join_Inner

Stéphane 

View solution in original post

3 REPLIES 3
slorin
Super User
Super User

More simple

let
Source = #"User Dimension Values",
List = Table.AddColumn(Source, "Dimension Values 2", each Expression.Evaluate("{" & Text.Replace([Dimension Values], "|", "} & {") & "}")),
Expand = Table.ExpandListColumn(List, "Dimension Values 2"),
Join_Inner = Table.NestedJoin(Expand, {"Dimension", "Dimension Values 2"}, #"Dimension Table", {"Dimension Code", "Code"}, "Dimension Table", JoinKind.Inner)
in
Join_Inner

Stéphane 

Gurps
Frequent Visitor

That's incredible.  Thank you so much for the solution.  

slorin
Super User
Super User

Hi

Split "Dimension Values"  by "|" into rows

Convert "100..208" into list with Expression.Evaluate

Expand list

Join with "Dimension Values"  (joinkind = Inner)

 

let
Source = #"User Dimension Values",
Split = Table.ExpandListColumn(Table.TransformColumns(Source, {{"Dimension Values", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Dimension Values"),
Convert_to_list = Table.TransformColumns(Split, {{"Dimension Values", each Expression.Evaluate("{"&_&"}")}}),
Expand = Table.ExpandListColumn(Convert_to_list, "Dimension Values"),
Join_Inner = Table.NestedJoin(Expand, {"Dimension", "Dimension Values"}, #"Dimension Table", {"Dimension Code", "Code"}, "Dimension Table", JoinKind.Inner)
in
Join_Inner

 

 Stéphane

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors