Forum Discussion
Change column data type depending the value
- 2 years ago
Hi RWRW
I noticed the changes tharunkumarRTK and ryan_mayu suggested but noticed that for both lines you are using "Changed Type" as the first argument.
The first argument for the second column added should refer to your previous step. If you refer to an earlier step, the steps in between will be missed.
Change the first argument of your second column (your text column) to refer to the step name for the first column (your numeric column).
In my example when creating the numeric column, my step name ended up as "Custom1" and the code is as follows:
= Table.AddColumn( #"Changed Type", "Numeric Result", each try Number.From([Result]) otherwise null )For my text column, i used the following:
= Table.AddColumn( Custom1, "Text Result", each if [Numeric Result] = null then [Result] else null )Notiice the change in the first arguments?
I hope this helps.
Hi RWRW
I noticed the changes tharunkumarRTK and ryan_mayu suggested but noticed that for both lines you are using "Changed Type" as the first argument.
The first argument for the second column added should refer to your previous step. If you refer to an earlier step, the steps in between will be missed.
Change the first argument of your second column (your text column) to refer to the step name for the first column (your numeric column).
In my example when creating the numeric column, my step name ended up as "Custom1" and the code is as follows:
= Table.AddColumn( #"Changed Type", "Numeric Result", each try Number.From([Result]) otherwise null )
For my text column, i used the following:
= Table.AddColumn( Custom1, "Text Result", each if [Numeric Result] = null then [Result] else null )
Notiice the change in the first arguments?
I hope this helps.
Hi,
You are right, after refering Numeric column it works perfectly.
I would like to send thanks all of you to spend time with my issue.
I'm really appreciated
Thanks again