Tableau - Similar function to SQL Group by - tableau-api

I have recently started using Tableau but am still very new to it. I don't know enough of the Tableau vocabulary to be able to find this answer through brute force googling. Hopefully some one here can help point me in a good direction.
I have a simple table of data, containing the columns and types: Date (Date), ID (Numerical), and Status (Text)
I want to be able to generate a report that has: Date, and Percent of the IDs on that date where the Status is "Complete."
In SQL I could do this by running a query along the lines of:
select date, (count(status like "Complete")/count(status)*100) from table
group by date;
Where can I look for this in Tableau? I tried creating a new Calculated measure in the sheet I am working on, but I couldn't find any built in functions that would add this ability. Thanks for any assistance.

So this should be pretty easy. In your tableau screen(when in a sheet) on the left you will see a column which is broken into two. On the top are the "Dimensions"(these are the things you will organise your data on, usually strings or dates) and on the bottom are the "Measures"(these are integers).
So under dimensions you should see "Date" and "Status". In the Dimensions you should see "Number of Records" and "ID"(this is your variable, you can convert it to a dimension by right clicking and selecting that option).
So what you need to do:
You just want status = complete, so drag your "Status" field into the Filter box(just to the right of the dimension column). You will get a pop up of the different types, select "Complete".
This has filtered your data source for only complete rows.
Drag you "Date" field to the "Rows" shelf, on the top of the screen. This will default to the Year of the date.
It will automatically go to a bar chart, change it to a table by selecting "Show Me" on the top right and select the table icon.
Double click on your "Number of Records" measure. This will add it to your sheet. This will now be auto summed per year.
To convert it to % of, right click on the measure in the Marks window(it should look like a green box "SUM(Number ....)"). Right click and select the option "quick table calculation", here select "Percentage of Total".
You will now have the % total per year for all records where status is equal to correct.
(Optional) - To adjust the date dimension, right click on the "Date" Pill(its up the top in the rows shelf). Hear you can see different options for quarter, month, day. You can change it to any of these or a custom data format.

Related

Difference between two measure totals in Tableau

Using the sample-Superstore data, I am trying to do a table calculation on the row totals, Sum(Sales) -Sum(Profit). I can get the result using this formula
TOTAL(SUM([Sales]))-TOTAL(SUM([Profit]))
But it will also show the value under Ship date 2016/2017,(I only need the total). Any ideas on how to remove the highlighted portion or an alternate way to achieve this?
Try one of two:
1) Try right-clicking the column where your red box is, TOTAL(SUM(SALES))... and then un-check 'show headers'. That will remove the column from your viz, however the calculations and sorting will still be there.
2) Adding the measure-names manually, rather than with the 'measure names' blue-box in the columns. Then, right click the column you wish to hide, and uncheck 'show headers'. That will remove the column from your viz, however the calculations and sorting will still be there. .

Tableau -- find total sales of the month

I have date-wise data of a month in Tableau and I want to know total sales of the month. Can anyone show how to do it?
Here is the snapshot of the issue:
First of all, I would advise you to go to the "Data Source" Panel on the bottom left and change the data type of the dimension "Date" to date instead of string. If this is not possible, please speak with your datasource admin. It might be a problem, that the dates are in different formats (like "1.07.06" and "1.11.2016").
After that you can simply choose the discrete MONTH(Date) dimension by rightklicking (blue pills). If you display data ranging over different years it is advised to keep the "YEAR(Date)" blue pill.
In the sample data it looks like this:
Steps to get total sales month wise
Drag your date into column shelf and change by Right click on date and change into month.
Drag sales into row shelf and Right click on measure and go into sum.so you will get total sales per month.

How can I add an Average column to this text table?

I'm building my first dashboard in Tableau and I'm just beginning to learn all the nuances. Right now, I have a basic text table as shown in the image below. I'm trying to add an "Average" column at then end which will give the average per "Assignee" across the 5 fiscal week's shown. I assume there must be a pretty simple way to do this, but I've searched all over and cannot figure it out. I've been able to change the "Grand Total" column to show averages, but not add an additional column so I can display both data points. Can anyone provide some insight into how to make this work?
There are two things you can do:
Go To "Analysis/ Total/ Show Row Grand Totals" and the go to "Analysis/ Total/ Total All Using/ Average" This will give you the row and column averages. Your questions sounds like you want row average but column total, so you should try the second option.
Create a calculated field with WINDOW_AVG(sum([YourMeasure])) (Replace [YourMeasure] with the meassure you want to average. I couldn't see the full name in the screenshot) I will call it AverageMeasure
Then drag the AverageMeasure pill into the rows shelf, right click it and choose "Discrete".
It should look something like this now (I used the Tableau default data set):
If you want to format the number properly, right click on the AverageMeasure in the measures section, choose Default Properties/ Number Format and choose whatever you prefer.

average of calculated rank in tableau

I would like to calculate the average of calculated rank for each competitor variable. I have trouble finding a solution as calculated rank is aggregated value. Can anyone help me with this?
It is the 2015_06 packaged file, and see "sheet 7".
https://drive.google.com/open?id=0B1PGq-fzDlKcWi03emxrQm1wdWs
I had a look at your workbook.
You need to do a change to your calculated field but then you can do it fairly easily with the table calculations.
Change the field Prem Rank to Rank(sum([Premium]),'asc')
Right click on it in the Marks section and make sure that "Compute Using" is set to "Table (Down)"
Create a calculated field with WINDOW_AVG([Prem Rank]) (I called it WINDOW_AVG([Prem Rank])).
Drop it into the column shelf
Right click on AVG(rank) -> Edit Table Calculation -> choose "Compute using: Advanced"
Change the settings according to this picture:
Right click on AVG(rank) again and choose "Discrete"
The result will be a table like this:
I think that is what you are after?

Show calculated measure in row?

I'm using Tableau Desktop 9.0 on OSX. I have data (loaded from a local CSV file) that looks like this:
code,org,items
0212000AA,142,10
0212000AA,143,15
0313000AA,142,90
0314000AA,143,85
I want a chart that shows the number of items beginning with 0212 as a percentage of all items, for each organisation. (I mean as a percentage of the organisation's items - for example, in the above, I would like to show 0.1 (10/(10+90)) for organisation 142.)
I have been able to get part way there, by adding org to Columns, and SUM(items) to Rows. Then by adding a Wildcard filter on code, for starts with 0212.
This shows me the number of items starting with 0212, by organisation.
But what I don't know how to do is show this divided by the value of all items for the organisation.
Is this possible in Tableau, or do I need to pre-calculate it before loading my data source?
One way is to define a calculated field called matches_code_prefix as:
left(code, 4) = "0212"
You can also define a parameter called, say, code_prefix to avoid hard coding the prefix string:
left(code, 4) = code_prefix
And then show the parameter control for code_prefix to allow the user to interact with it.
If you use this new field as a dimension to separate SUM(items) according to those that match the prefix and those that don't, you can then use a quick table calculation to get the percent of total.
For example, you can place org on the Rows shelf and matches_code_prefix on the Columns shelf, and SUM(items) on the Text shelf to make a table. Then under the analysis menu, turn on grand totals for both rows and columns to see the behavior. Next, right click on SUM(items) and choose Quick Table Calc->Percent of Total. Tableau will display the percents of total in the table.
If you want the percent of total defined differently than the default, then right click on the measure again and set Compute Using to a different value such as matches_code_prefix in your case. It's usually better to set compute using to a specific field.
If you only want to display the value for the matching case, select the column header you don't want to see and choose hide. You can also turn off the grand totals from the analysis menu when you are done.
When you are confident in the values in your table, you can turn it into a bar chart for example by moving matches_code_prefix to the detail shelf and the measure to the Columns shelf.
--
The above is the drag and drop approach. If you prefer to hard code everything in a single calculated field that is calculated on the database side, you could instead define a calculation such as:
zn(sum(if matches_code_prefix then items end)) / sum(items)
Then set the default number format for that field to display as a percentage