Forum Discussion
tc5pt
7 years agoRegular Visitor
Create custom column with values in same row as other column based on criteria
Hello, I have a single column as follows (numbers simplified): 100,000,000 200,000 200,500 201,000 201,500 101,000,000 202,000 202,500 203,000 I would like to create a new column,...
- 7 years agoThis is a basic custom function that does the trick:
Column A must be 'text' not 'number' or 'Int64'
(ColumnA as text) =>
let
Evaluation = if Number.FromText(ColumnA) < 100000000 then "null" else ColumnA
in
Evaluation
--------------------------------------------------------------------------------------
It Column A starts with a 0 then use:
(ColumnA as text) =>
let
Evaluation = if Text.Length(ColumnA) < 9 then "null" else ColumnA
in
Evaluation
--------------------------------------------------------------------------------------
Alternatively, use a custom column:
= Table.AddColumn(#"Changed Type", "Column B", each if Number.FromText([Column A]) < 100000000 then "null" else [Column A])
or
= Table.AddColumn(#"Changed Type", "Column B", each if Text.Length([Column A]) < 9 then "null" else [Column A])
Kjtakke
7 years agoNew Member
This is a basic custom function that does the trick:
Column A must be 'text' not 'number' or 'Int64'
(ColumnA as text) =>
let
Evaluation = if Number.FromText(ColumnA) < 100000000 then "null" else ColumnA
in
Evaluation
--------------------------------------------------------------------------------------
It Column A starts with a 0 then use:
(ColumnA as text) =>
let
Evaluation = if Text.Length(ColumnA) < 9 then "null" else ColumnA
in
Evaluation
--------------------------------------------------------------------------------------
Alternatively, use a custom column:
= Table.AddColumn(#"Changed Type", "Column B", each if Number.FromText([Column A]) < 100000000 then "null" else [Column A])
or
= Table.AddColumn(#"Changed Type", "Column B", each if Text.Length([Column A]) < 9 then "null" else [Column A])
Column A must be 'text' not 'number' or 'Int64'
(ColumnA as text) =>
let
Evaluation = if Number.FromText(ColumnA) < 100000000 then "null" else ColumnA
in
Evaluation
--------------------------------------------------------------------------------------
It Column A starts with a 0 then use:
(ColumnA as text) =>
let
Evaluation = if Text.Length(ColumnA) < 9 then "null" else ColumnA
in
Evaluation
--------------------------------------------------------------------------------------
Alternatively, use a custom column:
= Table.AddColumn(#"Changed Type", "Column B", each if Number.FromText([Column A]) < 100000000 then "null" else [Column A])
or
= Table.AddColumn(#"Changed Type", "Column B", each if Text.Length([Column A]) < 9 then "null" else [Column A])
- tc5pt7 years agoRegular Visitor
Thank you for your response. This is exactly what I asked for.
Is there anyway to make it return null (ie. no value) as opposed to "null" so I can use Fill Down?
- Kjtakke7 years agoNew MemberYes,
Replace “null” in the formula to any value you wish i.e “no value”
This only works if the column is set to text.