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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Compile source with multiple columns based on single column

I have been struggling with an issue. I have a source that returns a single column with multiple rows. The first 6 rows are meant to be column headings, and then the subsequent rows need fall under the coulns in the same sequence. (Not sure if that makes sense).

 

Eample of source:

Head 1
Head 2
Head 3
Head 4
Val 1
Val 2
Val 3
Val 4
Val 5
Val 6
etc

 

What I am trying to have:

Head 1Head 2Head 3Head 4
Val 1Val  2Val 3Val 4
Val 5Val 6etc 
    

 

I was thinking of finding a way to add a column to the source that just repeats the headings ovver and over. I can then pivot the table and use that coulm as attribute and the original column as value? (just haven't been able to figure out how to loop the firts couple of records containing the headings.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I found a solution

https://prathy.com/2018/07/list-repeat-in-powerquery-to-duplicate-rows/

 

let
Source = My example table,
#”Added Index” = Table.AddIndexColumn(Source, “Index”, 0, 1),
#”Inserted Modulo” = Table.AddColumn(#”Added Index”, “Modulo”, each Number.Mod([Index], 4), type number),
#”Integer-Divided Column” = Table.TransformColumns(#”Inserted Modulo”, {{“Index”, each Number.IntegerDivide(_, 4), Int64.Type}}),
#”Pivoted Column” = Table.Pivot(Table.TransformColumnTypes(#”Integer-Divided Column”, {{“Modulo”, type text}}, “en-GB”), List.Distinct(Table.TransformColumnTypes(#”Integer-Divided Column”, {{“Modulo”, type text}}, “en-GB”)[Modulo]), “Modulo”, “Column 1″),
#”Removed Columns” = Table.RemoveColumns(#”Pivoted Column”,{“Index”})
in
#”Removed Columns”

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

I found a solution

https://prathy.com/2018/07/list-repeat-in-powerquery-to-duplicate-rows/

 

let
Source = My example table,
#”Added Index” = Table.AddIndexColumn(Source, “Index”, 0, 1),
#”Inserted Modulo” = Table.AddColumn(#”Added Index”, “Modulo”, each Number.Mod([Index], 4), type number),
#”Integer-Divided Column” = Table.TransformColumns(#”Inserted Modulo”, {{“Index”, each Number.IntegerDivide(_, 4), Int64.Type}}),
#”Pivoted Column” = Table.Pivot(Table.TransformColumnTypes(#”Integer-Divided Column”, {{“Modulo”, type text}}, “en-GB”), List.Distinct(Table.TransformColumnTypes(#”Integer-Divided Column”, {{“Modulo”, type text}}, “en-GB”)[Modulo]), “Modulo”, “Column 1″),
#”Removed Columns” = Table.RemoveColumns(#”Pivoted Column”,{“Index”})
in
#”Removed Columns”

amitchandak
Super User
Super User

@ImkeF , can you help of this

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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