Tableau Percentage calculation - tableau-api

I am learning Tableau using sample dataset Sample Superstore. I am trying to find out, For a given period let us say January 2012, what percentage of sales were shipped using a specific product container (e.g. Jumbo Box)
When containers are in Rows, I get 2.22% and when I flip row to column and vice-versa I get 9.17%. Would appreciate some inputs to clarify this.
2.22%
9.17%

When you use table calculation the values will differ according to the viz and what type of calculation you have used. For example table down will calculate from top to bottom and table across will calculate from left to right. Like this you will see many other options for calculations.
In below example I have used running total with table across that is direction from Left to Right column values (2014,2015,2016,2017,2018).
Example:
Image1 - Original Data(without table calculation)
Data with table calculation - running total(table across)
In below image, Left to Right values are Ship Dates against Segments. Look at the Yellow color highlighted row. Year 2015 for Consumer Segment the sales value is 40,656 but in the original data(Image1) it is 24,635. The reason it is showing 40,656 is because table calculation is performed with running total by table across(left to right), so the original value 24,635 is added with previous Year's(2014) value 16,021. Hence 16021 + 24635 = 40656. It means Left value(16021) is added with the Right value(24635). This pattern will continue till the right most value.
Image2
Columns and rows are switched
In below image(Image3) Left to Right values are Segments against Ship Dates. The Columns and rows are switched. The value of Corporate Segment for the Year 2014 is changed to 25950(blue circle) because the left side value 16021 is added with the original value 9929(Image1).
Image3

Related

How to sort pivot based on measure and create a stacked bar chart

I am trying to create a stacked bar chart between 2 dimensions (one being week, other is a string - more below) and 1 measure. I am new to Looker.
But in order to get the stacked bar chart I figure that I need to
Create a pivot
Transpose the data
Create stacked bar chart
I am stuck with step 2 and 3.
The above steps is what I have thought could help me arrive at the visualization I want but would appreciate if there is any other solution for this.
Scenario:
I have a digital marketing data with me, where I am trying to create a visualization on ‘Leads’ generated,
I have 2 dimensions, 1 measure
Lead Created Week - Week on which a lead was created
Reason2 - reason a lead was created or what reason attracted the user most
Leads - count of leads
I have plotted the below visualization where I have created a pivot of week with Reason2 and Lead count under it and have plotted it on a stacked bar chart (as below).
Where each bar is a Reason (X-axis) and each color is the Week dimension, leads (count of leads) is in the Y-axis
Even though this is help what would be helpful is having ‘Week’ on X-axis, ‘Leads’ (count of leads) on Y-axis and ‘Reasons2’ dimension as a legend.
There is also one catch i.e., there are more than 100 distinct values in ‘Reason2’ field but I need to pick on Top 10 Reasons (i.e., the reasons that generated the most leads), which in the above screenshot I have achieved by limiting the display rows to 10 as the measure was already sorted.
I tried to flip around the pivot by having reason in pivot and Week as dimension, but if now the pivot is sorted in alphabetical manner and not by value of measures (screenshot below), I need the top 10 reasons which most leads per week.
How do I achieve the desired visualization of having week on X-axis with leads on Yaxis but only the top 10 Reasons should be generated.

Tableau How to show average of column

I have multiple column of survey answers from excel in tableau with the answers being 1,2,3,4,5. I want to show across the average for each column but in singular bar graph. For example row 1 would have a bar chart showing the average for that excel column, row 2 would show the average for its column etc. I would love the name of each excel column (Answer from survey) to be on the left side of the chart. However I can't figure it out since every time I drag the question into the row tab it starts showing (1-5) and doesn't just keep the average of the column. Thanks!
[
After replicating and trying what you described, my suggestions is to drag "Measure Values" (from Measure list on the sidebar) dropping in the "Columns" tray, and "Measure Names" on Rows.
Then use Measure Names as a filter, selecting the questions.
See Below:

Percent of Total for Categories Within Different Panes

I'm attempting to calculate the percent of total based off the the first column in each pane. However, table calculations only allow a calculation based off the each pane
SUM({ FIXED [Category]:SUM([Number of Records])})/TOTAL(SUM([Number of Records]))
does not produce the desired result.
It simply measures the number of records total in the category.
I cannot fixed the TOTAL function to category as it is a table calculation.
In the image, essentially I am trying to get all of the bars of the same color together without adjusting their heights.
enter image description here
I'm not really sure on what you're trying to do, when you say "percent of total based off the the first column in each pane" - does that mean total records with category 'furniture' & region 'central' shown as a percentage of all records, or total records with category 'furniture' shown as a percentage of all records with region 'central'? Or something else?
I have a feeling you can get to what you need by creating 2 fixed LOD calculations, or by fixing to 2 dimensions (e.g. { FIXED [Category],[Region]:SUM([Number of Records])}

Calculating % Complete

enter image description here
From the Image I need to calculate % complete for the order number 1.
Calculation for complete will be
(total number of points for status 'Delivered' / total number of points)*100
The value should be 57%
Can some one help with the calculated field?
Look at IIF in help files
SUM(IIF([Status]="Delivered",[Point],NULL)) / SUM([Point])
I assume your column named Order No. extends all the way down each row (i.e., each row should have a 1 as Order No. but the screenshot does not show that.
Also, the above only works if the status of "Delivered" is consistently cased, which it is not in the screenshot. If it is not consistently cased, wrap [Status] in an Upper function:
SUM(IIF(UPPER([Status])="DELIVERED",[Point],NULL)) / SUM([Point])
You can also get the effect you want, just by manipulating the Tableau user interface -- without needed to write calculated fields as #S. User18 showed. Both approaches work, but it helps to understand both alternatives.
As with #S. User18, I assume your column named Order No. is consistently filled in. I also assume [Order No.] is a dimension.
Place [Order No.] on a shelf, say Rows
Place [Status] on another shelf, say Columns
Place Sum([Point]) on a shelf, say Text
This shows the sum of the number of Points for each combination of the two dimensions: [Order No.] and [Status]
To convert the number of Points to a percentage, right click on Sum([Point]) on the marks card, and choose Quick Table calculation->Percent of Total
Similarly, right click on Sum([Point]) and experiment with different "Compute Using" settings to get the effect you want -- i.e. percent of each row, column, table etc. You can instead Edit the Table Calc if the preset Compute Using options don't get the effect you want.
Right click on any row or column headers that you want to hide - so if you only want to display the percentages for the Completed Status, hide the others. Don't exclude the others as that will change the calculations.
To understand more about Table Calculations, see the online help.

How do I display the total percentage and count together as a stacked bar chart without formatting all data to percentage values?

I asked this question (and this question) recently, and even though both have solutions, I am left with a new dilemma because each solution only works on an independent level (i.e. one solution won't work if the other solution is in place).
The problem is this: In Tableau, I discovered that by opting to display the data as a percentage of the total row value Analysis > Percentage of > Row, it resulted in the count value also being displayed as a number between 0 and 1 (i.e. percentage format, because of the aforementioned percentage-only setting).
Is there a way to achieve a 100.00% stacked bar which shows both percentage AND count, and which also isn't formatted to display all data as a percentage of the row total?
The screenshot shows what happens when both solutions are in place. Original screenshots are available within the body of each of the previous questions.
Note: I feel that the right way to go about it might be to normalise my data (bringing all values to a scale between 0 and 1), but being new to Tableau, I am not sure how this is achieved. If this is correct, I would appreciate a walkthrough.
Right click on the second SUM({Number of Records]) pill on the Label shelf, and clear the table calc. Edit your label if needed