5 Replies Latest reply on Jan 23, 2019 5:37 AM by Zhouyi Zhang

# Replacing a value with a different calculation

Hi Tableau friends,

I have an issue in replacing a value:

In my workbook you'll see each employee has one or more invoices.

Each invoice consists of different products and values for sales, purchase, calc1=sales-purchase and calc2= calc1 * 0.055).

Also for each product you'll find a product manager id.

Now calc2 has to be dcalculated diifferent for "John".

There we need total of calc2 if there's a product manager id = 200 or id= 100.

This result (155.87) has to be multiplyed with 0.085 = 13.25

See expected view below:

How to solve this problem?

I tried something in "calc_john" and "new Calc" but I can't combine the total 13.25.

Thanks for any hints.

• ###### 1. Re: Replacing a value with a different calculation

Hi Patrick,

Please check the data once. I didn't find product manager id = 200 or id= 100 for John emp.

Please find the screenshot for reference.

• ###### 2. Re: Replacing a value with a different calculation

No Johns calculation is based on product manager id of all products. That means if e.g. James, Jim or John himself sell products where product manager id = 200 or id= 100 then John will get commission.

• ###### 3. Re: Replacing a value with a different calculation

Hi, Patrick

Below is the screenshot of result for your reference.

Hope this helps

ZZ

• ###### 4. Re: Replacing a value with a different calculation

Thanks this is a great solution. Could you explain what's happening in this calculation?

• ###### 5. Re: Replacing a value with a different calculation

Hi, Patrick

Do you mean the function of Size() ?

size() is actually a portion in the view, in this case, grand total only has 1 portion, so we can use this to assign the value specifically.

and when size() <>1, it comes to the detail rows. And per your requirement, the calculaiton for John is different, so that's why I use if-else.

Hope this makes sense.

ZZ