none
expression.error cannot apply field access to the type list RRS feed

  • Question

  • Hello,

    I'm trying to transpose a simple list in two columns with this method found on the web:

    let
        Origine = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        #"Modificato tipo" = Table.TransformColumnTypes(Origine,{{"City", type any}}),
        #"Aggiunta colonna indice" = Table.AddIndexColumn(#"Modificato tipo", "Index", 1, 1),
        #"Aggiunta colonna personalizzata" = Table.AddColumn(#"Aggiunta colonna indice", "People", each {[Index]+1}[City]),
        #"Modificato tipo1" = Table.TransformColumnTypes(#"Aggiunta colonna personalizzata",{{"City", type text}, {"People", type text}})
    in
        #"Modificato tipo1"

    but I get the error in the title of this message.

    Thanks in advance,

    Franco

    Sunday, November 5, 2017 8:24 AM

Answers

  • Your reference {[Index]+1}[City] is incorrect.

    I guess you are looking for something like:

         #"Aggiunta colonna personalizzata" = Table.AddColumn(#"Aggiunta colonna indice", "People", each #"Aggiunta colonna indice"[City]{[Index]+1}),
    

    In your 2 columns, you will have the values from the original column shifted like:

    Row 1 with row 3
    Row 2 with row 4

    with errors in the last 2 rows.

    Probably, this is not the best solution for what you are looking for, so maybe you can share a representative example with fake source data and intended result, then we can probably come up with a better solution.

    • Marked as answer by Franco Fornari Sunday, November 5, 2017 11:23 AM
    Sunday, November 5, 2017 11:00 AM

All replies

  • Your reference {[Index]+1}[City] is incorrect.

    I guess you are looking for something like:

         #"Aggiunta colonna personalizzata" = Table.AddColumn(#"Aggiunta colonna indice", "People", each #"Aggiunta colonna indice"[City]{[Index]+1}),
    

    In your 2 columns, you will have the values from the original column shifted like:

    Row 1 with row 3
    Row 2 with row 4

    with errors in the last 2 rows.

    Probably, this is not the best solution for what you are looking for, so maybe you can share a representative example with fake source data and intended result, then we can probably come up with a better solution.

    • Marked as answer by Franco Fornari Sunday, November 5, 2017 11:23 AM
    Sunday, November 5, 2017 11:00 AM
  • Hello, 

    you are absolutely right, that row of code is incorrect, but it has been created automatically by this formula I found on the web:

    #[City]{[Index]+1} (without "Aggiunta colonna indice");

    Now all works fine.

    Many thanks

    Sunday, November 5, 2017 11:23 AM