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.
I got it for Numbers
What about for text?
Thanks a lot
= Table.AddColumn(#"Changed Type", "Text", each if Value.Type([Result]) = Text.Type then [Result] else null,type text)
If the post helps please give a thumbs up
If it solves your issue, please accept it as the solution to help the other members find it more quickly.
Tharun
- RWRW2 years agoHelper III
Hi again,
Something is incorrect? Copy and paste...
Thanks
- tharunkumarRTK2 years agoSuper User
Your column name is 'Result', with upper case R
- RWRW2 years agoHelper III
Yes yes I realized, I already changed and still not working