Filter Duplicates in Tableau - tableau-api

I am playing with tableau dashboard, I have below data.
.
so I have 2 users for Facebook, 2 users for Google and 1 user for Yahoo.
I created a Bar chart to show the number of users per application, like below
its showing 4 users for Facebook, 4 for Google and 2 for Yahoo, basically it's just giving me a number of records.
How do I filter duplicates and just show correct values?

Probably you are using count function, you need to count distinct instead.
Select your dimension in the column/row shelf, right click on it, and select option Measure Count (Distinct).

Related

Campaign performance in Tableau

I am doing campaign analysis in Tableau where I want to see the percentage of leads that has seen 1 campaign,percentage of leads that has seen two campaign and so on in pie chart filter by month and region before they convert to customer.
For e.g in below sample data set there are 5 leads in February of which only lead id abc has seen two campaigns and rest four has seen one campaigns. So the view will be pie chart where 20%(1 out of 5) of lead has seen two campaigns and rest 80% has seen 1 campaigns. If March is selected then pie chart will be 100% one campaign as there is only 1 lead.
If in region filter US is selected then there are three unique leads(abc,efg,klm) in february and view will be pie chart with 33% lead has seen two campaigns and rest two i.e 77% has seen 1 campaign.
I got idea from the link here but not able to do it when month and region filter is added.
Campaign analysis in Tableau
Just add two calculated fields both LOD, as detailed below-
Campaigns per Lead as
{ FIXED [Lead id] : COUNT([Campaign])}
'Measure_val` as
COUNTD([Lead id]) / ATTR({ FIXED : COUNTD([Lead id])})
Format Measure_val as per cent in number format.
Add your filters to view, add both filters to CONTEXT by right clicking them (Note: In order to have filters calculated before LOD calculation. Normal filter calculates the view after LOD fields are calculated). Check whether filters have been greyed out.
Convert Campaign per Lead to dimension by right clicking it.
Add Measure_val to size, angle and text(for label-optional) and Campaign per Lead to color and text(optional again) and you're done.
Do tell if it worked.

How do I find the average age of users based on value of another column?

I have a dataset for health procedures with each patient listed under Index_Num. Most patients are listed several times as they have had several services. There is a column with their age.
There is another column called Portal_Use, which says "Yes" or "No" based on whether the user is a portal user.
The question I am trying to visualize in Tableau is the Average Age of Portal Users.
I created a group of the Index_Num, but don't know where to go from there. I'm essentially looking for a bar chart that has one bar for portal users and one bar for non portal users with the average age. This would be very easy if there weren't multiple rows per patient.
Based on your explanation I have used below data to generate the sample workbook.
Use your Portal_Use flag as a Columns
Add Age as an AVG value in Row section
From Show me section select the Type of Bar char you needed
Above will give you desired results as per below.
I hope this helps!!!

Calculate Number of Hours worked in Tableau

Number of hours is fixed (8) multiplied by the number of distinct days a user has worked.
I need this number as text to insert into a title on a dashboard.
However I need to separate this number by the User filter from another worksheet. When I apply this, I just get the total number of distinct days (not per user).
This is the calculated field I have created so far:
countd(DATETRUNC('day',[_StartDate]))
Try using a Level of Detail calc fixing on user. something like {fixed user : countd(DATETRUNC('day',[_StartDate]))}

Graph based on the user filter selection

On a tableau dashboard there are 2 filters and a bar graph.
The filters are 1. to select top or bottom customers
2. how many ex:5,10,15 etc
when the user selects top and 5 in the respective filters then top5 customers have to show in the bar graph.
if the user selects bottom ,10 in the respective filters then bottom 10 customers have to shown in the graph.
how to achieve this when the data contains only customers details and their billing amount ?
Instead of filter, you can go with the Parameter for getting the result. I have done the top and bottom multiple times in many of the tableau visualizations and its so easy.
Below are the steps to achieve your requirement.
Create a parameter that will allow you to select top and bottom
Create another parameter that will allow you to select the desired numbers like 5, 10, 15 etc.
Here i have created a parameter that will have values from 10 to 50 in a step size of 10.
Create a calculated field that will subset data based on the parameters chosen
In the above screenshot, I am using the top site parameter and creating a conditional statement that will show the states based on the value chosen in the site parameter and the value for that state.
Put the calculated field in the filter and select show and click ok in the filter box.
Now the view will show the top count based on the value selected in the parameter.
Please note the calculation is for top N and for bottom N you need to change the calculation.
Hope this will help you. I can provide you a workbook if you need.

Top 10 and items upon user's demand

fellow Tableau Developer,
Take the super store database for example, it is easy to draw a histogram displaying the sales amount of each customer and to only display the Top 10 customers.
It is also easy to build a multiple dropdown filter to let the user to specify some customers at the user's will.
But, is it possible to combine the two of them, namely, to display Top 10 customers and in the same graph display a few other customers (possibly not in the Top 10) on the user's demand?
Here is a straight forward solution that works with Tableau Desktop, but not as useful currently on Tableau Server. The viz still works on Server, but you can can't alter the list of specific users on Server.
Here's the approach.
Create a set to represent your Top 10 customers -- a computed set. (right click on the [Customer Name] field, and Create Set)
Create a second set to represent your specific list of customers of interest -- a static set (select [Customer Name] and Create Set)
Create a combined set to be the union of both sets and place it on the filter shelf. (select both sets, right click and create a combined set)
Use your combined set on the filter shelf, row shelf, in calculations, as desired.
A desktop user can edit the Interesting Customers set. Sure wish there was a control similar to "show filter" for editing set members.
If you'd like this feature more flexible in Desktop, and even available on Tableau Server, upvote the following idea
https://community.tableau.com/ideas/5193