Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Move data if it includes negative values

JamesG2806
7 - Meteor

Hi,

 

I want to see how I can move data over to blank coloumn called debit if they include negative values. So I have data that looks like the below. I was everything that is negative to move over to debit column on the same row. 

 

Example:

 

 

Item    Balance        Debit

AB         709.09        

CD         929.00

DS         -312.01

SQ         -2304.01

WS         201.00

 

Outcome 

 

Item    Balance        Debit

AB         709.09        

CD         929.00

DS                           -312.01

SQ                           -2304.01

WS         201.00

6 REPLIES 6
cplewis90
13 - Pulsar
13 - Pulsar

Hey @JamesG2806,

 

You should be able to use a formula tool to update the Debit column using the formula:

if [Balance] < 0 then [Balance] else [Debit] endif

JosephSerpis
17 - Castor
17 - Castor

Hi @JamesG2806 I have mocked a workflow that produces your output. Negative_Values_Example.png

JamesG2806
7 - Meteor

hey @cplewis90  thanks for the quick reply, unfortunately when I use this formula I get < is an invalid operator, Any ideas why ? 

cplewis90
13 - Pulsar
13 - Pulsar

Is your balance field a string or numeric field? A string field would not know how to interpret the <0 aspect of the formula.

 

If it is a string try:

if contains([Balance],"-") then [Balance] else [Debit] endif

bpatel
Alteryx
Alteryx

It may be because your field data types are not numeric. You can use the select tool to change the data types to doubles and that should solve the issue. Let me know if this works!

JamesG2806
7 - Meteor

@cplewis90 Perfect that worked silly mistake thanks for the answers 

Labels