How do I do this.....?

cruzrji1

New Member
Joined
Apr 22, 2016
Messages
4
Hello guys,

Im new wiht the PowerBI tools and trying to keep on...

Also, I dont know how to call what I need to do even in spanish (my native language) so I´ll give an example

Before that, I'd like to state that this is a real world problem for me, Im working in a large construction project and this example is an over simplification of my problem, so any help will be very appreciated!

=)

I have three tables kind of sources...

Table 1:


LVL 1Description LvL 1
A1Civil
A2Mecanica
A3Electricidad

<tbody>
</tbody>

Table 2:
LvL 2Description LvL 2
B1Cimentaciones
B2Muros
B3Compresores
B4Reactores
B5Cableado
B6Transformadores

<tbody>
</tbody>

<tbody>
</tbody>


Table 3 :


LvL 1LvL 2
A1B1
A1B2
A2B3
A2B4
A3B5
A3B6

<tbody>
</tbody>

Then I have a fourth table :

Table 4:


LvL 1
A1
A1
A3
A2
A3
A2
A3

<tbody>
</tbody>

How do I get this result from table 4?:


LVL 1Description LvL 1LvL 2Description LvL 2
A1CivilB1Cimentaciones
A1CivilB2Muros
A1CivilB1Cimentaciones
A1CivilB2Muros
A3ElectricidadB5Cableado
A3ElectricidadB6Transformadores
A2MecanicaB3Compresores
A2MecanicaB4Reactores
A3ElectricidadB5Cableado
A3ElectricidadB6Transformadores
A2MecanicaB3Compresores
A2MecanicaB4Reactores
A3ElectricidadB5Cableado
A3ElectricidadB6Transformadores

<tbody>
</tbody>


I filled the last table manually, of course I could use a lot of vlookups or some vba or something like that, but I Know there is a simpler way using Power Tools, maybe PowerQuery or PowerPivot I dont know...

Please Help!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
A suggestion. On your 4th table, you could go with:

Col A: Table3!ColA
Col B=Vlookup(Col A,Table1!B:B,1,FALSE)
Col C: Table3!ColC
Col D=Vlookup(Col A,Table1!B:B,1,FALSE)

I think this is an easy way to do that. If you create a Table, formulas will extend automatically. That's one formule for each columns, pretty light!
 
Upvote 0
Try this:

let
Table1 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRU0lFyzizLzFGK1QFyjYBc39TkxLzM5ESIiDFQxDUnNbmkKDM5MyUxRSk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Col1 = _t, Col2 = _t]),
Table2 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjJU0lFyzsxNzStJTM7Mz0stVorVAQobAYV9S4vyoVxjkKr83IKi1OL8IpgaE6BgUGpicglCyBSkLjEpJzUxJR8iYgYUCSlKzCtOyy/KBYqClcYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Col1 = _t, Col2 = _t]),
Table3 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRU0lFyMlSK1YGxjSBsIxDbGIltAmEbg9imSGwzpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Col1 = _t, Col2 = _t]),
Table4 = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRUitVBUMYQyggHLxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
MergeTbl3 = Table.NestedJoin(Table4,{"Column1"},Table3,{"Col1"},"NewColumn",JoinKind.LeftOuter),
ShowRelation = Table.ExpandTableColumn(MergeTbl3, "NewColumn", {"Col2"}, {"NewColumn.Col2"}),
MergeTbl1 = Table.NestedJoin(ShowRelation,{"Column1"},Table1,{"Col1"},"NewColumn",JoinKind.LeftOuter),
ShowTbl1Desc = Table.ExpandTableColumn(MergeTbl1, "NewColumn", {"Col2"}, {"NewColumn.Col2.1"}),
MergeTbl2 = Table.NestedJoin(ShowTbl1Desc,{"NewColumn.Col2"},Table2,{"Col1"},"NewColumn",JoinKind.LeftOuter),
ShowTbl2Desc = Table.ExpandTableColumn(MergeTbl2, "NewColumn", {"Col2"}, {"NewColumn.Col2.2"}),
#"Reordered Columns" = Table.ReorderColumns(ShowTbl2Desc,{"Column1", "NewColumn.Col2.1", "NewColumn.Col2", "NewColumn.Col2.2"})
in
#"Reordered Columns"

Please note the duplicates because of Table 3 and Table 4.
 
Last edited:
Upvote 0
Thanks for the answer, I´m guessing that code must be on power query, now I only have to learn how to use it...
 
Upvote 0
In Power Query, either in Excel or Power BI Desktop, open the advanced editor and paste the code above.

This was only an example. You will have to change the data source of Table1, Table2 and Table3.
 
Upvote 0

Forum statistics

Threads
1,214,893
Messages
6,122,118
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top