
1. Re: Calculation of reallocation
Matt Lutton Oct 3, 2013 7:44 AM (in response to Camille Cosnefroy)You should be able to write calculations using these fields, regardless of which line they are in. Can you post a workbook with sample data and what you've tried? Maybe I am not understanding the problem.

2. Re: Re: Calculation of reallocation
Camille Cosnefroy Oct 3, 2013 8:23 AM (in response to Matt Lutton)My point is that I would like to create the "reallocated sales" field.

Data.xlsx 8.7 KB

Tableau workbook.twbx.zip 11.5 KB


3. Re: Re: Calculation of reallocation
Matt Lutton Oct 3, 2013 8:35 AM (in response to Camille Cosnefroy)I understand. You can separate out the sales numbers using calcs like:
"Product A Sales"
IF attr([Product])="Product A" then Sum(Sales) end
Then, you should be able to write your calculation, using these calculated fields.
"Product A Reallocation" would be:
[Product A Sales] + [Product A Sales]/([Product A Sales] + [Product B Sales]) * [Product C Sales]
I haven't tested this, so there may be a better solution. I would think calculating this in your data source would be easier, but I could be wrong.

4. Re: Re: Calculation of reallocation
Matt Lutton Oct 3, 2013 8:36 AM (in response to Matt Lutton)Also, I don't know if X is supposed to represent one sales figure, or the SUM of sales for the product. That will make a difference, as well.

5. Re: Re: Calculation of reallocation
Camille Cosnefroy Oct 3, 2013 8:49 AM (in response to Matt Lutton)Indeed, X is a sum of several sales for the product.
Moreover, product A is in reality a group of products and I cannot use it into a calculated field.
It's not possible to calculate it in my data source because this allocation is at a macro level (sum of product) and not at a product level.

6. Re: Re: Calculation of reallocation
Matt Lutton Oct 3, 2013 8:54 AM (in response to Camille Cosnefroy)If you use a calculation to create your groupings instead of Tableau's grouping option, you can then reference the groups in a calc. But that would turn into a lot of calculationsmaybe someone else has a better approach?

7. Re: Re: Re: Calculation of reallocation
Camille Cosnefroy Oct 3, 2013 9:32 AM (in response to Matt Lutton)I tried your solution in my example (attached) and nothing appears for product reattribution fileds. Any ideas?

Tableau workbook.twbx.zip 11.4 KB


8. Re: Re: Re: Calculation of reallocation
Matt Lutton Oct 3, 2013 9:39 AM (in response to Camille Cosnefroy)
Nope, I have no idea why this is happening. Another approach altogether may be called for, I'm not the most experienced user and am trying to teach myself new things too. 
9. Re: Calculation of reallocation
Camille Cosnefroy Oct 3, 2013 9:43 AM (in response to Matt Lutton)Thanks a lot Matthew, i'll try to find a solution.
I hope someone else would be able to help me.

10. Re: Calculation of reallocation
. Indumon Oct 3, 2013 10:10 AM (in response to Camille Cosnefroy)1 of 1 people found this helpfulHello Camille, I have created one calculated field Reallocation using the case statements.
Calculation Allocation :
Case Attr([Product])
When "Product A" Then
Window_max([Product A sales])+Window_max([Product A sales])/(Window_max([Product A sales])+Window_max([Product B sales]))*Window_max([Product C sales])
When "Product B" Then
Window_max([Product B sales])+Window_max([Product B sales])/(Window_max([Product B sales])+Window_max([Product A sales]))*Window_max([Product C sales])
when "Product C" Then 0
End
Output:
I hope this will help you...
Unfortunately I created the workbook in Tableau 8.1, I will upload the workbook after recreate in 8.0

11. Re: Calculation of reallocation
Matt Lutton Oct 3, 2013 10:09 AM (in response to . Indumon)See, there's always someone with a good solution!

12. Re: Re: Calculation of reallocation
. Indumon Oct 3, 2013 10:15 AM (in response to Camille Cosnefroy)Here you go! Workbook attached

Reallocation.twbx.zip 11.5 KB


13. Re: Calculation of reallocation
Camille Cosnefroy Oct 3, 2013 10:41 AM (in response to . Indumon)Wah great! Thanks a lot Indumon!
The only little problem is that "Product A", "Product B" and "Product C" are groups so I can't use them in the formula.
Do I have to use "contains()" to group into the calculation field?

14. Re: Calculation of reallocation
. Indumon Oct 3, 2013 12:10 PM (in response to Camille Cosnefroy)No Problem. Can you tell me the hierarchy of your data?
My understanding is Product A, B, and C are Product group and there is another level (column) has products of each group, am I right? If yes then we need to change the formula from Window_Max to Window_Sum