13 Replies Latest reply on Sep 20, 2012 11:36 PM by sreekanth.upputuri

# Calculation help required on  pervious value

Hi All,

I need some calculation help on my workbook

I have one measure objects name has like  “count “  on top of this one I have created two other calculated fields like below

Percentage count” (SUM([COUNT]) / TOTAL(SUM([COUNT]))*100)

“Delta%” ((PREVIOUS_VALUE([Percentage Count] )- [Percentage Count])*100)

When I use this objects  in workbook the “Delta%” calculation are not working properly

For example  week 36 percentage count minus week 35 percentage count (36-33 = 3 ) like that it has to come but mine will come  0

Can you please see the attached screen short

• ###### 1. Re: Calculation help required on  pervious value

Hi Sreekanth,

Are you able to post this as a packaged workbook (twbx file)?

-Tracy

• ###### 2. Re: Calculation help required on  pervious value

Hi Tracy ,

Actually i have connected to the live data . when i publish it . it will ask the data base credentials  .

if it possible could you give it me sample data base i will do it same way

• ###### 3. Re: Calculation help required on  pervious value

Hi All ,

• ###### 4. Re: Calculation help required on  pervious value

Hi,

This issue bit me once...

PREVIOUS_VALUE() is an iterative function that returns the previous value of the function from the previous row in the partition, using whatever is between the () as the value for the first row in the partition.

To get just the value from the prior row in the partition, what you are looking for is LOOKUP([Percentage Count],-1), assuming that Percentage Count is an aggregate. If not, you will need to turn it into an aggregate using ATTR(), MIN(), etc.

Jonathan

• ###### 5. Re: Calculation help required on  pervious value

Hi Jonthan,

Can you please give me a small example  if it possible . and also please look into my sample one and my first thread of the issue in detail

• ###### 6. Re: Calculation help required on  pervious value

Here's the alternative calc: ((LOOKUP([Percentage Count],-1) - [Percentage Count])*100)

You'll need to post a packaged workbook (.twbx), .twb files don't have data in them.

Jonathan

• ###### 7. Re: Calculation help required on  pervious value

Hi Jonathan,

please see the attached sample workbood

• ###### 8. Re: Calculation help required on  pervious value

Hi,

You're still only attaching a .twb. In Tableau, choose the File->Export Packaged Workbook... menu item to export a packaged workbook (.twbx) that you can upload.

• ###### 9. Re: Calculation help required on  pervious value

Hi Jonathan ,

Please see the attached packaged workbook

• ###### 10. Re: Calculation help required on  pervious value

See the attached, I did the following:

- Created a Percentage Sales (copy) calc that doesn't do the *100, and instead formatted the output (by right-clicking on the measure in the Measures window and choosing Format... from the context menu) to show %.

- Created a Delta from Prior calc with the following calc: [Percentage Sales (copy)] - LOOKUP([Percentage Sales (copy)],-1). This matches your description of wanting week 36 - week 35 from your initial post.

- The Percentage Sales (copy) has a Compute Using of Product to get a percentage of sales for each product within each week. In this view, this is the same as Table (Down).

- The Delta from Prior has an Advanced... Compute Using of Date, with the sort on Date/Minimum/Ascending. This is necessary because the view has been sorted with Date/Descending, and the calc needs to be sorted with Date/Ascending to work properly. In addition, since Delta from Prior has Percentage Sales (copy) as a nested table calc, the nested calc needs it's Compute Using set to Product.

Cheers,

Jonathan

• ###### 11. Re: Calculation help required on  pervious value

Hi Jonathan,

I have also done the same procedure but i am not getting the exact result for the "Delta From Prior" please see the attached workbook and let me  know where i was miss the setps

• ###### 12. Re: Calculation help required on  pervious value

The Compute Using for Percentage Sales (copy) inside Delta from Prior was set to Date, when it needs to be set to Product.

• ###### 13. Re: Calculation help required on  pervious value

Hi Jonathan,

Thanks for your help it resolved the issue ..