8 Replies Latest reply on Jun 18, 2018 1:35 AM by Sohan Jawar

# Calculation problem

Hi,

Can anyone help me what is wrong with the below formula.

Requirement: To calculate Share difference. Example=April 2018 share = Val/Total(Val) - April 2017 share

ZN(SUM([Val])/TOTAL(zn(SUM([Val]))))-

(ZN(SUM([Val])) - LOOKUP(ZN(SUM([Val])), -12)) /Total((ZN(SUM([Val])) - LOOKUP(ZN(SUM([Val])), -12)))

• ###### 1. Re: Calculation problem

Pretty difficult to answer this question without seeing your data or a sample workbook.

• ###### 2. Re: Calculation problem

1. Try to create the calculation field for Total and order it by Manufacturer Asia.

2. Another calculation Lookup should be ordered by months.

• ###### 3. Re: Calculation problem

But Serg just wanted to know why my formula above is not valid

• ###### 4. Re: Calculation problem

Niranjan Banarje,

it's not valid because you're trying to use 2 table calculations simultaneously. That's why Tableau don't get the right order to solve. That's why I woul recommend you to use 2 calculated fields: one for total and second for lookup.

• ###### 5. Re: Calculation problem

I tried to separately calculate the Total for  previous 12 months data is not happening.

It will be helpful if you can share an sample calculation

• ###### 6. Re: Calculation problem

No problem. Please, attach the workbook with sample data and required results. I will reply with all details.

• ###### 7. Re: Calculation problem

Hi Serg,

For example (Superstore data set is used):

MIN({ FIXED [Category], DATETRUNC('month', [Order Date]): SUM([Sales])})

/

MIN({ FIXED DATETRUNC('month', [Order Date]):SUM([Sales])})

-

LOOKUP(MIN({ FIXED [Category], DATETRUNC('month', [Order Date]):SUM([Sales])}), -12)

/

LOOKUP(MIN({ FIXED DATETRUNC('month', [Order Date]):SUM([Sales])}), -12)

Trust this helps.

D

• ###### 8. Re: Calculation problem

Hi Niranjan,

Try to create different calculated fields for your calculation.

TotalValue = Total(SUM([Value)])

CurrentMonthValue = ZN(LOOKUP(SUM([Value],0))

12MonthPreviousValue = ZN(LOOKUP(SUM([Value],-12))

Share = [CurrentMonthValue]/[TotalValue]) - ([12MonthPreviousValue]/[TotalValue])

This should be computed along the Month and year of the date which you are using in the view.

Regards

Sohan.