none
How to convert a list of items into a list of lists where each list contains two items RRS feed

  • Question

  • Hi !

    I have the following output list in PQ :    {"Apple", "Orange", "Banana", "Pear", "Grape", "Pineapple"}

    I would like the output to be a list of lists such as:  {{"Apple", "Orange"}, {"Banana", "Pear"}, {"Grape", "Pineapple"}}

    How can this be achieved? Also how could we extend the above to look like this: {{"Apple", "Orange", "Banana"}, {"Pear", "Grape", "Pineapple"}}

    Thanks
    Sam

    Wednesday, July 24, 2019 4:18 AM

Answers

  • Hi,

    It's quite simple now:

    let
        Source = {"Apple", "Orange", "Banana", "Pear", "Grape", "Pineapple"},
        split = List.Split(Source, 2)
    in
        split
    • Marked as answer by SamNaik Wednesday, July 24, 2019 9:57 PM
    Wednesday, July 24, 2019 8:29 AM