2 Replies Latest reply on Oct 26, 2013 12:36 PM by Ramon Martinez

# How do I create a calculation based on the value of a cell?

In my viz of personal spend, I am trying to make what I think is a calculated field that subtracts the amount if a corresponding cell value is 'Credit'

Here is basically what I have

DateDescriptionOriginal DescriptionAmountTransaction TypeCategoryAccount NameLabel
10/20Food @ TargetMilk5.00DebitGroceriesCash
10/21Return @ WalmartOJ3.00CreditGroceriesCredit

So basically, if the Transaction Type of a row is equal to 'Credit' then I want my running sum to subtract the value in the Amount column. In this example, the Net Sum would be a total of 2.00 (5-3=2)

I tried this following formula, but it hasn't done anything:

If [Transaction Type] = "Credit" then Amount  * -1

END

Any help would be greatly appreciated

• ###### 1. Re: How do I create a calculation based on the value of a cell?

Hi Brian,

I think you are just missing an else part. If you don't put the else condition all other transaction type Amount will return null except 'Credit'.

If [Transaction Type] = "Credit" then Amount  * -1 else Amount END

• ###### 2. Re: How do I create a calculation based on the value of a cell?

Hi Brian,

As Indumon said, you need to complete your formula. For intance I created a calculated field called Balance with following formula:

IIF([Transaction Type]="Credit",-1*[Amount],[Amount])

Than I used the new measure Balance to calculate the total expenses adding it to Text.

Take a look at the attached workbook.

Best,

Ramon