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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Tinus1905
Resolver I
Resolver I

Rows in columns

Hi,

 

I want rows into columns in PowerBi query editor. 

 

From this:

 

Tinus1905_0-1702995836839.png

Into this:

 

Tinus1905_1-1702995859649.png

 

Is that possible? 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @Tinus1905 ,
Here are the steps to resolve.
1. Use "Group by" transformation to remove duplicate combination.
2. Again use "Group By" transformation and add an Index column.
3. Create a custom column by using the Index number such as "IP1", "IP2" etc.
4. Use pivot to get the resultset.   

Below are the Power Query transformation steps you can check. Replace the source as per your code

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLRNTDTNTIwMlbSUQpILUktUvBKTM4uzs8D8g2N9IxNTPXAlFKszgCqNjEy1DM01DMxNdMzh6g2RVLtk5mXkqjgkl+Oy2g8io1NLPQsLcGKjUlUHAsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Name = _t, IP = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Name", type text}, {"IP", type text}}),
#"Grouped Rows-GetMaxIP" = Table.Group(#"Changed Type", {"Date", "Name", "IP"}, {{"MaxIP", each List.Max([IP]), type nullable text}}),
#"Removed Columns-Duplicates" = Table.RemoveColumns(#"Grouped Rows-GetMaxIP",{"IP"}),
#"Renamed Columns-IP" = Table.RenameColumns(#"Removed Columns-Duplicates",{{"MaxIP", "IP"}}),
#"Grouped Rows-GetIndex" = Table.Group(#"Renamed Columns-IP", {"Name", "Date"}, {{"IndexTbl", each _, type table [Date=nullable date, Name=nullable text, IP=nullable text]}}),
#"Added Custom-IndexColumn" = Table.AddColumn(#"Grouped Rows-GetIndex", "Index", each Table.AddIndexColumn([IndexTbl],"Index",1)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom-IndexColumn",{"Index"}),
#"Expanded Index" = Table.ExpandTableColumn(#"Removed Other Columns", "Index", {"Date", "Name", "IP", "Index"}, {"Date", "Name", "IP", "Index.1"}),
#"Added Custom1" = Table.AddColumn(#"Expanded Index", "IPIndex", each "IP" & Number.ToText([Index.1])),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Index.1"}),
#"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[IPIndex]), "IPIndex", "IP")
in
#"Pivoted Column"

View solution in original post

@Anonymous ; this works for me, but now I have another table with 180 different IP numbers. 

So now I change all the IP numbers in 2 words; "Home" and "Office". 

How do I use the formula on this?

 

Tinus1905_0-1703768500501.png

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Tinus1905 ,
Here are the steps to resolve.
1. Use "Group by" transformation to remove duplicate combination.
2. Again use "Group By" transformation and add an Index column.
3. Create a custom column by using the Index number such as "IP1", "IP2" etc.
4. Use pivot to get the resultset.   

Below are the Power Query transformation steps you can check. Replace the source as per your code

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLRNTDTNTIwMlbSUQpILUktUvBKTM4uzs8D8g2N9IxNTPXAlFKszgCqNjEy1DM01DMxNdMzh6g2RVLtk5mXkqjgkl+Oy2g8io1NLPQsLcGKjUlUHAsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Name = _t, IP = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Name", type text}, {"IP", type text}}),
#"Grouped Rows-GetMaxIP" = Table.Group(#"Changed Type", {"Date", "Name", "IP"}, {{"MaxIP", each List.Max([IP]), type nullable text}}),
#"Removed Columns-Duplicates" = Table.RemoveColumns(#"Grouped Rows-GetMaxIP",{"IP"}),
#"Renamed Columns-IP" = Table.RenameColumns(#"Removed Columns-Duplicates",{{"MaxIP", "IP"}}),
#"Grouped Rows-GetIndex" = Table.Group(#"Renamed Columns-IP", {"Name", "Date"}, {{"IndexTbl", each _, type table [Date=nullable date, Name=nullable text, IP=nullable text]}}),
#"Added Custom-IndexColumn" = Table.AddColumn(#"Grouped Rows-GetIndex", "Index", each Table.AddIndexColumn([IndexTbl],"Index",1)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom-IndexColumn",{"Index"}),
#"Expanded Index" = Table.ExpandTableColumn(#"Removed Other Columns", "Index", {"Date", "Name", "IP", "Index"}, {"Date", "Name", "IP", "Index.1"}),
#"Added Custom1" = Table.AddColumn(#"Expanded Index", "IPIndex", each "IP" & Number.ToText([Index.1])),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Index.1"}),
#"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[IPIndex]), "IPIndex", "IP")
in
#"Pivoted Column"

@Anonymous ; this works for me, but now I have another table with 180 different IP numbers. 

So now I change all the IP numbers in 2 words; "Home" and "Office". 

How do I use the formula on this?

 

Tinus1905_0-1703768500501.png

 

Anonymous
Not applicable

Hi,

 

If your other table containing list if IPs and categoriesed as Home/Office, then you can merge your primary data table with the mapping table and then follow the pivot/unpivit functionalities to get the desired outcome.

 

Hope this will address your requirement.

 

Thanks,

Santo

some_bih
Super User
Super User

Hi @Tinus1905  check link for un/pivot columns





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.