Forum Discussion

AhmadBakr's avatar
AhmadBakr
Helper IV
2 years ago
Solved

Error while using Table.TransformColumns

Any one can help why I am getting this error message:

Expression.Error: We cannot apply field access to the type Number.
Details:
Value=1.387
Key=FY2023-CIF

When I use this transformation:

= Table.TransformColumns( #"Replaced Value", { { "FY2023-Jan", each [#"FY2023-CIF"] } } )

 

I want to replace the values in "FY-2023-Jan" column with those in "FY2023-CIF" column

 

  • Hi AhmadBakr 

    Table.TransformColumns only passes the value in the column being transformed as an argument to the function provided in the 2nd argument. This means that it cannot reference values in columns other than the one being transformed.

     

    However, you can use Table.ReplaceValue like this:

    = Table.ReplaceValue(#"Replaced Value", each [#"FY2023-Jan"], (_) as number => [#"FY2023-CIF"], Replacer.ReplaceValue, {"FY2023-Jan"})

     

    See here.

     

    Does this work for you?

     

    Regards

2 Replies

  • Hi AhmadBakr 

    Table.TransformColumns only passes the value in the column being transformed as an argument to the function provided in the 2nd argument. This means that it cannot reference values in columns other than the one being transformed.

     

    However, you can use Table.ReplaceValue like this:

    = Table.ReplaceValue(#"Replaced Value", each [#"FY2023-Jan"], (_) as number => [#"FY2023-CIF"], Replacer.ReplaceValue, {"FY2023-Jan"})

     

    See here.

     

    Does this work for you?

     

    Regards

  • OwenAuger thank you very much for the info and the workaround.

     

    Pardon my late response, I have been extremly overloaded and working late nights. This is the first time I log into the forum since I posted the question.