Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

SQL Query Used

SELECT [Sheet1$].[Level] AS [Level], [Sheet1$].[Parent Category Label] AS [Parent


Category Label], [Sheet1$].[Product Category] AS [Product Category], [Sheet1$].
[Sales] AS [Sales], 1 AS Path FROM [Sheet1$] UNION ALL SELECT [Sheet1$].[Level]
AS [Level], [Sheet1$].[Parent Category Label] AS [Parent Category Label],
[Sheet1$].[Product Category] AS [Product Category], [Sheet1$].[Sales] AS [Sales],
203 AS Path FROM [Sheet1$]
Tableau Calculations
1. Index
// Counting along PathID
INDEX()
2. Max Sales
WINDOW_MAX(MAX([Sales]))
3. Label
WINDOW_MAX(MAX([Parent Category Label]))
4. MaxLevel
WINDOW_MAX(MAX([Level]))
5. Size of Slice
// The size (ratio) of each slice compared to the entire circle defined by the sum of
all sales in Level 1
[MaxSales]/WINDOW_SUM(IIF([MaxLevel]=1,[MaxSales]/203,0))
6. Edges
IF [MaxLevel] > LOOKUP([MaxLevel],-1) THEN PREVIOUS_VALUE(0)
ELSEIF [MaxLevel] <= LOOKUP([MaxLevel],-1) THEN PREVIOUS_VALUE(0) +
LOOKUP([Size of Slice],-1)
ELSE PREVIOUS_VALUE(0) END
7. Slice Level
WINDOW_MAX(MAX([Level]))
8. X
// Each slice is a polygon made from 102 points. First and last points are at the
center of the chart (0,0)
// Which leaves 100 points for the arc hence 99 segments to span that angle. This
could be any number.

// I picked 100 since it appears to give a very smooth curve.

IF([Index]<>WINDOW_MAX([Index]) AND [Index]>=(WINDOW_MAX([Index])+1)/2)


THEN
([Slice Level]+5.8)
* COS(WINDOW_MAX(2*PI())*[Edges]+
(WINDOW_MAX([Index])-([Index]+1))*WINDOW_MAX(2*PI())*[Size of Slice]/
(((WINDOW_MAX([Index])-1)/2)-1))

ELSEIF([Index]=WINDOW_MAX([Index]) OR [Index]<(WINDOW_MAX([Index])+1)/2)

THEN

([Slice Level] + 5)
* COS(WINDOW_MAX(2*PI())*[Edges]+
(((IIF([Index]=WINDOW_MAX([Index]), 1,[Index])-1)*WINDOW_MAX(2*PI())*[Size of
Slice]/((((WINDOW_MAX([Index])-1)/2)-1)))))
END
9. Y
// Each slice is a polygon made from 102 points. First and last points are at the
center of the chart (0,0)
// Which leaves 100 points for the arc hence 99 segments to span that angle. This
could be any number.
// I picked 100 since it appears to give a very smooth curve.

// Each slice is a polygon made from 102 points. First and last points are at the
center of the chart (0,0)
// Which leaves 100 points for the arc hence 99 segments to span that angle. This
could be any number.
// I picked 100 since it appears to give a very smooth curve.

IF([Index]<>WINDOW_MAX([Index]) AND [Index]>=(WINDOW_MAX([Index])+1)/2)


THEN
([Slice Level]+5.8)
* SIN(WINDOW_MAX(2*PI())*[Edges]+
(WINDOW_MAX([Index])-([Index]+1))*WINDOW_MAX(2*PI())*[Size of Slice]/
((((WINDOW_MAX([Index])-1)/2)-1)))

ELSEIF([Index]=WINDOW_MAX([Index]) OR [Index]<(WINDOW_MAX([Index])+1)/2)

THEN

([Slice Level] + 5)
* SIN(WINDOW_MAX(2*PI())*[Edges]+
(((IIF([Index]=WINDOW_MAX([Index]), 1,[Index])-1)*WINDOW_MAX(2*PI())*[Size of
Slice]/(((WINDOW_MAX([Index])-1)/2)-1))))
END
Table Calculation Levels

You might also like