5 Replies Latest reply on Jul 27, 2016 7:13 AM by Emanuele Daloiso

# Fee calculation

Hello,

I'm trying to create a formula to calculate fees based on invoice date.

The short formula without the invoice date references works well, but actually when I try to differentiate the values based on the invoice date I get the following error: "Syntax error (maybe you are missing an identifier)".

Thanks,

Emanuele

• ###### 1. Re: Fee calculation

Hi Emanuele,

Your formula at the start is invalid.

You are writing

IF something = something AND

ELSEIF

It needs to be either;

IF something = something AND somethingelse = somethingelse THEN dothis

ELSEIF

or;

IF something = something THEN dothis

ELSEIF

• ###### 2. Re: Fee calculation

Hi Tom,

I've changed the formula in the following but it seems still uncorrect.

IF YEAR([DATA FATTURA])=YEAR(TODAY()) AND RUNNING_SUM([Fatture (++XYZ BI)].[FATTURATO YTD]) <= 5000 THEN 0.15

ELSEIF YEAR([DATA FATTURA])=YEAR(TODAY()) AND RUNNING_SUM([Fatture (++XYZ  BI)].[FATTURATO YTD]) <= 10000 THEN 0.18

ELSEIF YEAR([DATA FATTURA])=YEAR(TODAY()) AND RUNNING_SUM([Fatture (++XYZ  BI)].[FATTURATO YTD]) > 10000 THEN 0.2

ELSEIF YEAR([DATA FATTURA])=YEAR(TODAY())+1 AND RUNNING_SUM([Fatture (++XYZ  BI)].[FATTURATO YTD]) <= 5000 THEN 0.15

ELSEIF YEAR([DATA FATTURA])=YEAR(TODAY())+1 AND RUNNING_SUM([Fatture (++XYZ  BI)].[FATTURATO YTD]) <= 10000 THEN 0.22

ELSEIF YEAR([DATA FATTURA])=YEAR(TODAY())+1 AND RUNNING_SUM([Fatture (++XYZ  BI)].[FATTURATO YTD]) > 10000 THEN 0.25

ELSEIF YEAR([DATA FATTURA])=YEAR(TODAY())+2 AND RUNNING_SUM([Fatture (++XYZ  BI)].[FATTURATO YTD]) <= 5000 THEN 0.22

ELSEIF YEAR([DATA FATTURA])=YEAR(TODAY())+2 AND RUNNING_SUM([Fatture (++XYZ  BI)].[FATTURATO YTD]) <= 10000 THEN 0.28

ELSEIF YEAR([DATA FATTURA])=YEAR(TODAY())+2 AND RUNNING_SUM([Fatture (++XYZ  BI)].[FATTURATO YTD]) > 10000 THEN 0.35

END

I'm afraid the year invoice part is bringing to the error.

What do you think?

Thanks,

Emanuele

• ###### 3. Re: Fee calculation

It's impossible for me to tell without knowing what the error is, where the error occurring and being able to apply this to some sample data. Please upload a Tableau Packaged Workbook so I can replicate.

• ###### 4. Re: Fee calculation

Try to use Sum inside running_sum (Since they must be aggregated)

• ###### 5. Re: Fee calculation

Hi Tom,

Thanks,

Emanuele

2016-07-20 17:51 GMT+02:00 Tom W <tableaucommunity@tableau.com>:

Tableau Support Community

Fee calculation

Forums - View the full discussion