Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

How to combine column 1 and column 2 such that all the elements in column 2 move below column 1?

Hi everyone,    I want to combine variable, variable1 and variable2 into one column and value, value1 and value2 into another column which means the total number of rows will be 36. So at the...
  • AlB's avatar
    5 years ago

    Anonymous 

    Create a function from the code above (named  "function_")

    (inputT_ as table)=> 
    let
        colNames_ = Table.ColumnNames(inputT_),
        colNum_ = Table.ColumnCount(inputT_),
        auxList_ = List.Numbers(0,colNum_/2),
        auxList2_ = List.Transform(auxList_, each Table.RenameColumns(Table.SelectColumns(inputT_,List.Range(colNames_, _*2,2)),{{colNames_{_*2}, "Value"}, {colNames_{_*2+1}, "Variable"}})), 
        TFinal_ = Table.Combine(auxList2_)
    in
        TFinal_

     Then you can apply it on the query you showed above:

    let
     Source = Web.Page(Web.Contents("https://finviz.com/quote.ashx?t=FB&ty=c&p=d&b=1")),
     res_ = function_ (Source{0}[Data])
    in
     res_

     

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers 

     

  • Jimmy801's avatar
    5 years ago

    Hello Anonymous 

     

    did any of the answer suit your requirements? If yes, please mark them as solution please

     

    BR

     

    Jimmy