Forum Discussion

Mic1979's avatar
Mic1979
Post Partisan
1 year ago
Solved

Combine list of elements

Dear all,

 

I got some tables from a colleague, and from them I created the following lists:

The first one, named High_Runner_Sanatory_AM_Function,

And the second one, named High_Runner_Sanatory_AM_Analog_Input

 

I want to created a list like this:

I created then the following custom function:

 

(Element_1, Element_2) =>

let

    Combination     = List.Zip({{Element_1},

                                {Element_2}})

in

    Combination

 

Invoked in this way:

let

    Source = #"List_Combination (2)"("High_Runner_Sanatory_AM_Function", "High_Runner_Sanatory_AM_Analog_Input")

in

    Source

 

And I got this:

 

If I expand the list, I have:

 

 

Where do I make mistake?

Thanks for your support.

  • Hi Mic1979 

     

    (Element_1 as list, Element_2 as list) as list => List.Zip({Element_1,Element_2})

     Stéphane

4 Replies

  • m_dekorte's avatar
    m_dekorte
    Resident Rockstar

    Hi Mic1979,

    If I understand correctly, all you'd need to do is Zip both lists, like so:

    List.Zip({ High_Runner_Sanatory_AM_Function, High_Runner_Sanatory_AM_Analog_Input})

     

    That will output a list like this:

    {
       {"ON/OFF", "0-24V"},
       {"Prop.", "0-10V SP"}
    }

     

    I hope this is helpful

  • Mic1979's avatar
    Mic1979
    Post Partisan

    Hello m_dekorte 

    If I apply the List.Zip directly on the parameters, I this way:

     

    let
    Source = List.Zip({High_Runner_Sanatory_AM_Function, High_Runner_Sanatory_AM_Analog_Input})
    in
    Source

     

    I get the following:

       ==> 

     ==> 

    It is Ok, but how to get the list expanded?

     

    On the other hand, I need to apply this to multiple cases, so the best is to have a custom function:

    So I created this:

     

    (Element_1, Element_2) =>

    let
    Combination = List.Zip({{Element_1},{Element_2}})

    in
    Combination

     

    invoked in this way:

     

    let
    Source = #"List_Combination (2)"(High_Runner_Sanatory_AM_Function, High_Runner_Sanatory_AM_Analog_Input)
    in
    Source

    In this case I get this:

     ==> 

     

     I am wondering why I get two different results.

     

    Thanks.

     

     

  • Hi Mic1979 

     

    (Element_1 as list, Element_2 as list) as list => List.Zip({Element_1,Element_2})

     Stéphane