- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Formula to make a new column
I have a table with four columns, and I am trying to make a new column based off of the available columns. Here is my script:
dtq = current data table();
a = dtq << New Column( "E",
Formula(
If(
Is Missing( :A ) & Is Missing( :B ), Abs( :C ),
Is Missing( :A ), Abs( :C / (:B - :D) ) ,
Is Missing( :B ), Abs( :C / (:D - :A) ),
//If !Is Missing( :A ) & !IsMissing( :B ),
//then do Abs( :C / (:B - :D) ) and Abs( :C / (:D - :A) ) and choose the gretaer value out of the two.
)
)
);
The first three conditions work, however the condition with values present in both A and B is something I am unable to work out. How can I make my script calculate 2 formulas and add the greater value out of these to my column in the table? Thank you for any help.
2 ACCEPTED SOLUTIONS
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Formula to make a new column
You want the Max() function.
dtq = Current Data Table();
a = dtq << New Column( "E",
Formula(
If(
Is Missing( :A ) & Is Missing( :B ), Abs( :C ),
Is Missing( :A ), Abs( :C / (:B - :D) ),
Is Missing( :B ), Abs( :C / (:D - :A) ),
!Is Missing( :A ) & !Is Missing( :B ),
Max( Abs( :C / (:B - :D) ), Abs( :C / (:D - :A) ) )
)
)
);
-Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Formula to make a new column
dtq = current data table();
a = dtq << New Column( "E",
Formula(
If(
Is Missing( :A ) & Is Missing( :B ), Abs( :C ),
Is Missing( :A ), Abs( :C / (:B - :D) ) ,
Is Missing( :B ), Abs( :C / (:D - :A) ),
Max(Abs( :C / (:B - :D) ) ,Abs( :C / (:D - :A) ) )
)
)
);
Jim
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Formula to make a new column
You want the Max() function.
dtq = Current Data Table();
a = dtq << New Column( "E",
Formula(
If(
Is Missing( :A ) & Is Missing( :B ), Abs( :C ),
Is Missing( :A ), Abs( :C / (:B - :D) ),
Is Missing( :B ), Abs( :C / (:D - :A) ),
!Is Missing( :A ) & !Is Missing( :B ),
Max( Abs( :C / (:B - :D) ), Abs( :C / (:D - :A) ) )
)
)
);
-Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Formula to make a new column
dtq = current data table();
a = dtq << New Column( "E",
Formula(
If(
Is Missing( :A ) & Is Missing( :B ), Abs( :C ),
Is Missing( :A ), Abs( :C / (:B - :D) ) ,
Is Missing( :B ), Abs( :C / (:D - :A) ),
Max(Abs( :C / (:B - :D) ) ,Abs( :C / (:D - :A) ) )
)
)
);
Jim