none
Converting a Text Value Into a Fieldname Suitable for Use with Table.AddColumn() RRS feed

  • Question

  • How can I convert the text value, "field1", for use with Table.AddColumn() as shown below? ... 

    =Table.AddColumn( Source, "Custom", each [field1] )


    Tuesday, June 28, 2016 3:53 PM

Answers

  • Hi,

    You can use Record.Field or Record.FieldOrDefault functions:

    https://msdn.microsoft.com/en-us/library/mt253579.aspx?f=255&MSPPError=-2147217396

    • Marked as answer by Mark Weisman Tuesday, June 28, 2016 5:46 PM
    Tuesday, June 28, 2016 5:38 PM
    Moderator

All replies

  • the 3rd argument of this function needs to be a function, so these statements should work:

    =Table.AddColumn( Source, "Custom", each [field1] )

    or

    =Table.AddColumn( Source, "Custom", each "field1" )

    (Not totally sure what exactly you need)


    Imke Feldmann TheBIccountant.com

    Tuesday, June 28, 2016 4:05 PM
    Moderator
  • Thanks, I edited my original post.
    Tuesday, June 28, 2016 4:08 PM
  • Hi,

    You can use Record.Field or Record.FieldOrDefault functions:

    https://msdn.microsoft.com/en-us/library/mt253579.aspx?f=255&MSPPError=-2147217396

    • Marked as answer by Mark Weisman Tuesday, June 28, 2016 5:46 PM
    Tuesday, June 28, 2016 5:38 PM
    Moderator
  • Yes, that's it!!!  Here's how I used it ... 

    = Table.AddColumn( #"Removed Other Columns", "ColCount", each Text.Length( Record.Field ( _ , MyDelimitedColumn )) - Text.Length( Text.Replace( Record.Field ( _ , MyDelimitedColumn ), MyDelimiter, "" )) + 1 )


    Tuesday, June 28, 2016 5:47 PM