I have a data set like this
Name Occupation Payment Principal Interest
Amy Nurse 100 90 15
Becky Teacher 80 100 20
Catherine Nurse 90 75 15
John Engineer 90 80 12
Tom Teacher 120 100 20
... ... ... ... ...
I'd like to create side-by-side(Payment) stacked chart:
Row: Occupations
Column1 : stacked(Sum of Interest and Sum of LP Principal) by occupation
Column2 : Only Sum of LP Payment by occupation
Can anyone give me hint how to make it?
Your data is not in the correct format for the required chart and you need to do some data prep.
Pivot all three measure fields from the data source page.
create a calculation to define the column for each data type
Build the chart as below and hide the header for column field.
One approach that avoids reshaping your data is to use the measure names and measure values placeholder fields to create the stacked bar chart.
See below
Related
looking to have a basic text grid by month by product, and then have a single filter on only 2 of the measures. For example:
Measures Filter
------------------
[ ] Sales <-- only show this
[X] Quantity <-- and this as options
[ ] Interest (don't show in filter)
[ ] Fee ( don't show in filter)
JAN | FEB | MAR | APR | MAY | etc ...
products
ITEM1 x x x x x
ITEM2 x x x x x
ITEM3 x x x x x
So the user can basically toggle between Sales or Quantity, and whichever they click on will fill out the x by month.
I was able to get this to work for everything except only showing the 2 measures I want to filter for. It only shows all measures for me in the filter and I can't figure out how to hide them.
What I did was
Drag Date to columns
Drag Product and MeasureNames to Rows
Can someone please help me on getting this correct? Any help or guidance is appreciated!
This is not the correct use case of FILTERS. Filters are normally used to filter (read subset) the data (read rows). Say for example If your dataset has 1000 rows/records and you want some report/visual/aggregation on say 500 rows (based on some criteria of course) you have to filter the data. For selection of argument (user based) in some report/viz, etc. Parameters are used.
Your desired example output is also a perfect case of use of Parameters. You may proceed as follows-
Step-1 Create a parameter (say parameter 1) with values as SALES and QUANTITY.
Step-2 Create a calculated field (say CF1) with the following calculation
CASE [parameter 1]
WHEN 'SALES` THEN [sales]
WHEN 'Quantity' then [Quantity]
END
Note: It is assumed that your field/column names in dataset are sales and Quantity
Step-3 Build your view (Crosstab here) with
months on Columns shelf
products on rows shelf
CF1 on text in Marks card (alternatively just double click it)
Choose measure for aggregation of CF1 as desired (default will be sum)
Step-4 right click paramter 1 and click show parameter. (select desired measure for aggregation in crosstab)
VOILA your desired view is complete. Good luck.
There is another options to add to Anil's good suggestion. You can also use Measure Names as a filter. Hide all measures apart from those you want in the filter, then put Measure Names on the filter shelf.
However, this means you can't use the hidden measures from the data source elsewhere, which can be a deal breaker. Duplicating the data source is a way around that limitation.
But if you only want to show the 2 measures and are happy with single select, then choosing the measure by parameter is the better option, as Anil suggests.
I am trying to calculate average of 2 columns in another column in Tableau but difficult part is grand total is not getting average instead it is the sum of 3rd calculated field.
A B Calculated field
10 5 2
6 3 2
T 16 8 4 (Here I should get 2 instead it is taking sum of column)
Here I am unable to write separate formula for row totals and grand totals, Only one formula (Calculated Field) is allowed and when I am dragging on sheet it is by default aggregating to sum.
Note: I am expert in Crystal and BO but beginner in Tableau.
Update
Code used for LoD
{FIXED [Product Category]: AVG([Sales])}
Below image is what I got after implementation I have tried with 2 columns but the result is same if I use only one column (I am trying to get the average of sales)
You are almost there - the Grand Total by default does a SUM function you just have use the Total All Using --> Average option.
Output : Level wise SUM(Profit) later averaged across columns and rows. (Show Column Grand Total & Show Row Grand Total active)
Update: Answering the question below. To get the Row-wise avg (which is Cat1-vag in this case) you could just drop the measure and change it to AVG(). Since you needed in a Calculated Field you could use a Simple FIXED LOD. You can also uncheck aggregated measures from Analysis dropdown and have no Dimension in column or row like unlike what this example shows and still get three different averages. Cheers.
{FIXED [Cat1]:AVG([Profit])}
Check out this very smart work around from Joe Mako.
https://community.tableau.com/thread/112791
create a calc field like:
IF FIRST()==0 THEN
WINDOW_AVG(SUM([Sales]),0,IIF(FIRST()==0,LAST(),0))
END
duplicate your Category field
place "Category (copy)" on the level of detail
set the compute using for the calc field pill to use "Category (copy)"
The window function in the calculated field only takes into account what's in the view, and aggregate based on those number.
I am new to Tableau. I have a dataset made up of year, has a measure that can be one of many values, and a corresponding value for that measure. Example:
YEAR MEASURE Value
1988 Number of Cars 10
1989 Number of Cars 15
1988 Number of Peds 5
1989 Number of Peds 6
This is just an example data set. But, I want to create bar char for Number of Cars and a line graph for Number of Peds. How can this be done? I was told I can do this without reorganizing the dataset (into a wide data set).
thanks
jason
You can create two calculated fields to separate Cars from Peds counts as follows:
if [measure name] = 'cars' then value end
Repeat for Peds. Then follow these instructions for dual axis.
https://onlinehelp.tableau.com/current/pro/desktop/en-us/multiplemeasures_dualaxes.html
I'm trying to calculate the percentage in Tableau from a value in a table.
For example. I have a table that contains the following
Name Value
a 10
b 20
c 30
Ref 100
How can I have the percentages calculated based on the Ref value like for example a/Ref
Name Value Percentage (x/Ref)
a 10 10%
b 20 20%
c 30 30%
Thanks
You can either
use tableaus built in functionality:
Right click the measure pill and select "quick table calculation -> Percentage of total"
2.Use calculated fields.
Create a calculated field(Analysis->Create Calculated Field) called reference. As the value enter the integer you want.
Create a second calculated field call it percentage. Here enter the mathematical formula to get a percentage using the reference calculated field as your total.
So something like:
[Value] / [refrence] *100
You don't need the reference calc field, you could just hard code the value into the calculation.
Drag the percentage calculated field into the row shelf.
Does WINDOW_SUM actually sort the data? what if my table looks like this
userid | price
1 | 5
2 | 6
3 | 7
1 | 10
and say I need the output like below (just one column)
total_price_by_user
15
6
7
clearly I need a sum distinct as a calculated field so I can do the below but I wonder if window_sum actually sorts the data or not and the userid should not be displayed in the output so it should exactly look like above?
WINDOW_SUM(IIF(ATTR([userid])==ZN(LOOKUP(ATTR([userid]), -1)), 0, [price]))
You are working too hard.
Just put make sure Userid is a discrete (blue) dimension and then place it on a shelf, such as the Rows shelf. Then make sure price is a continuous (green) measure and place it on a shelf, such se the Columns shelf. Tableau will aggregate the data and display the sum of all the price values for each user id.
To change a field from dimension to measure, simply drag it to the appropriate section in the data pane on the left (i.e. the pane showing all the field names)
If you want Tableau to sort your users by sum, click the sort button in the toolbar.
Save table calculations like Window_Sum() and lookup() for the occasional special cases that the simpler approaches don't cover.