Forum Discussion

viferenc's avatar
viferenc
Icon for Helper II rankHelper II
5 years ago
Solved

Need help mulitple line

Dear All,

 

I would like to ask fo your help.

 

I have in Table 1 a column with the following text.

Column A

Car

Bus

Airplane

Boot

 

In Table 2 I have column with the following text.

Column A

1

2

3

4

...

 

I would like to combine it power query that I have new table with the following way.

 

Column A        Column B

1                          Car

2                          Car

3                          Car

4                          Car

...                         Car

1                         Bus

2                         Bus

3                         Bus

4                         Bus

...                         Bus

1                       Airplane

2                       Airplane

3                       Airplane

4                       Airplane

...                      Airplane

1                      Boot

2                      Boot

3                      Boot

4                      Boot

...                     Boot

 

My goal is to show the text among each other ten times or hundred times with an extra column of the numbers startring always from 1 for each text.

 

Thank you for your help

 

Feri

 

 

 

  • Add a Custom Column to Table2 as:

    Table.Column(Table1,"Column A")

    Expand the List to Rows to this:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyaKsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ColumnA = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"ColumnA", Int64.Type}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.Column(Table1,"Column A")),
        #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom")
    in
        #"Expanded Custom"
  • viferenc - I would recommend posting your follow-up issue as a new post. It is very likely someone else has a solution or better understanding of what you describe.

3 Replies

  • ChrisMendoza's avatar
    ChrisMendoza
    Icon for Resident Rockstar rankResident Rockstar

    Add a Custom Column to Table2 as:

    Table.Column(Table1,"Column A")

    Expand the List to Rows to this:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyaKsXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ColumnA = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"ColumnA", Int64.Type}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.Column(Table1,"Column A")),
        #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom")
    in
        #"Expanded Custom"
    • viferenc's avatar
      viferenc
      Icon for Helper II rankHelper II

      Dear Chris,

       

      thank you for your help.

       

      I had to modify a little bit, as I had to use more line.

      See the formula below: (sorry it is in German)

       

      let
      Quelle = List.Numbers(1, 1000),
      #"In Tabelle konvertiert" = Table.FromList(Quelle, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
      #"Hinzugefügte benutzerdefinierte Spalte" = Table.AddColumn(#"In Tabelle konvertiert", "Custom", each Table.Column(Table1,"ColumnA")),
      #"Expanded Custom" = Table.ExpandListColumn(#"Hinzugefügte benutzerdefinierte Spalte", "Custom")
      in
      #"Expanded Custom"

       

      The problem is when the query is running, it is loading millions of line although altogether it should be only 92000 lines. (1000*92) 

       

      Is there any possibility to reduce the number of loading lines because at the end I have to use instead of 1.000 lines 1.000.000 lines

      I calculated to load 92*1.000.000=92.000.000 lines and not billions of lines during the loading process. (I  have 92 different trucks, they run 1.000.000 km and for each km I´m planning to show average fuel consumption to be able to calculate for each transport the fuel consumption)

       

      If there is any possibility to help me it would be great.

       

      Thank you very much for your help.

       

      Feri

      • ChrisMendoza's avatar
        ChrisMendoza
        Icon for Resident Rockstar rankResident Rockstar

        viferenc - I would recommend posting your follow-up issue as a new post. It is very likely someone else has a solution or better understanding of what you describe.