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

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.

Reply
PSB
Helper III
Helper III

transform row into column

How to convert column 3 value into row in Power Query?

 

Before   
S_NodeIdS_CellValue1234.1Value1234.2
M1WA6375AK1WA6375A21gNBId1351878
M1WA6375AK1WA6375A22nRPCI215
M1WA6375AK1WA6375A23cellLocalId

303

 

After    
S_NodeIdS_CellgNBIdnRPCIcellLocalId
M1WA6375AK1WA6375A211351878215303

 

PSB_0-1664671458108.png

 

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @PSB 

 

Download example file with code

 

 

This works

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8jUMdzQzNjd1VNJR8oaxjQyBvHQ/J88UIG1obGpoYW6hFKuDS7URkJcXFODsCaSNDE3xqDQG8pJTc3J88pMTc8CmGxsYK8XGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [S_NodeId = _t, S_Cell = _t, Value1234.1 = _t, Value1234.2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"S_NodeId", type text}, {"S_Cell", type text}, {"Value1234.1", type text}, {"Value1234.2", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Value1234.1]), "Value1234.1", "Value1234.2"),
    #"Filled Up" = Table.FillUp(#"Pivoted Column",{"nRPCI", "cellLocalId"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Up", each ([gNBId] = 1351878))
in
    #"Filtered Rows"

 

unpiv11.png

But may need some teaking to work with a larer data set.  Post back here if you are having issues with the rest of your data.

 

regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

7 REPLIES 7
PhilipTreacy
Super User
Super User

Hi @PSB 

 

Download example file with code

 

 

This works

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8jUMdzQzNjd1VNJR8oaxjQyBvHQ/J88UIG1obGpoYW6hFKuDS7URkJcXFODsCaSNDE3xqDQG8pJTc3J88pMTc8CmGxsYK8XGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [S_NodeId = _t, S_Cell = _t, Value1234.1 = _t, Value1234.2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"S_NodeId", type text}, {"S_Cell", type text}, {"Value1234.1", type text}, {"Value1234.2", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Value1234.1]), "Value1234.1", "Value1234.2"),
    #"Filled Up" = Table.FillUp(#"Pivoted Column",{"nRPCI", "cellLocalId"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Up", each ([gNBId] = 1351878))
in
    #"Filtered Rows"

 

unpiv11.png

But may need some teaking to work with a larer data set.  Post back here if you are having issues with the rest of your data.

 

regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


I followed same steps from your example and still getting error.

 

PSB_3-1664677701294.png

 

PSB_2-1664677680002.png

 

PSB_0-1664677641572.png

PSB_1-1664677652529.png

 

 

 

@PSB 

 

Your initial data/example is laid out differently to the 2nd lot of data you've shown.

 

Please supply some representative sample data so we don't have to type everything in by hand.

 

regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hello Philip, 

Here is the data.

I want to convert "Value1234.1" to row with it's respective values from first three columns and Value1234.2 column. 

Example: 

PSB_0-1664687025187.png

 

Data:

S_NodeIdS_CellAttributeValue1234.1Value1234.2
M1WA6375AK1WA6375A31lwNeighborRelgNBId1314147
M1WA6375AK1WA6375A31lwNeighborRelgNBId1344046
M1WA6375AK1WA6375A31lwNeighborRelgNBId1336352
M1WA6375AK1WA6375A31lwNeighborRelgNBId1344046
M1WA6375AK1WA6375A31lwNeighborRelgNBId1336352
M1WA6375AK1WA6375A31lwNeighborRelgNBId1336352
M1WA6375AK1WA6375A31lwNeighborRelgNBId1320445
M1WA6375AK1WA6375A31lwNeighborRelgNBId1337382
M1WA6375AK1WA6375A31lwNeighborRelgNBId1320445
M1WA6375AK1WA6375A31lwNeighborRelgNBId1314621
M1WA6375AK1WA6375A31lwNeighborRelgNBId1351878
M1WA6375AK1WA6375A31lwNeighborRelgNBId1346518
M1WA6375AK1WA6375A31lwNeighborRelgNBId1322062
M1WA6375AK1WA6375A31lwNeighborRelgNBId1341083
M1WA6375AK1WA6375A31lwNeighborRelgNBId1320445
M1WA6375AK1WA6375A31lwNeighborRelgNBId1314148
M1WA6375AK1WA6375A31lwNeighborRelgNBId1333527
M1WA6375AK1WA6375A31lwNeighborRelgNBId1314256
M1WA6375AK1WA6375A31lwNeighborRelgNBId1337382
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId1
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId2
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId2
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId1
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId1
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId3
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId2
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId302
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId1
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId2
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId3
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId1
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId1
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId303
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId3
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId1
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId303
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId2
M1WA6375AK1WA6375A31lwNeighborRelcellLocalId303
M1WA6375AK1WA6375A31lwNeighborRelnRPCI190
M1WA6375AK1WA6375A31lwNeighborRelnRPCI29
M1WA6375AK1WA6375A31lwNeighborRelnRPCI649
M1WA6375AK1WA6375A31lwNeighborRelnRPCI19
M1WA6375AK1WA6375A31lwNeighborRelnRPCI702
M1WA6375AK1WA6375A31lwNeighborRelnRPCI644
M1WA6375AK1WA6375A31lwNeighborRelnRPCI148
M1WA6375AK1WA6375A31lwNeighborRelnRPCI853
M1WA6375AK1WA6375A31lwNeighborRelnRPCI162
M1WA6375AK1WA6375A31lwNeighborRelnRPCI694
M1WA6375AK1WA6375A31lwNeighborRelnRPCI656
M1WA6375AK1WA6375A31lwNeighborRelnRPCI102
M1WA6375AK1WA6375A31lwNeighborRelnRPCI42
M1WA6375AK1WA6375A31lwNeighborRelnRPCI860
M1WA6375AK1WA6375A31lwNeighborRelnRPCI170
M1WA6375AK1WA6375A31lwNeighborRelnRPCI390
M1WA6375AK1WA6375A31lwNeighborRelnRPCI44
M1WA6375AK1WA6375A31lwNeighborRelnRPCI406
M1WA6375AK1WA6375A31lwNeighborRelnRPCI68
PSB
Helper III
Helper III

static

Dinesh_Suranga
Continued Contributor
Continued Contributor

@PSB ,

Hi,

Is Column "Value1234.1" values dynamic or static?

Thank you

static

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.