Issue when creating category charts in Tableau? - tableau-api

I have a table with different columns called "Bajo conocimiento...", "Exceso de...", etc. Each column has discrete values: 1, 2, 3 or empty (NULL). I need to count the number of occurrences of 1, 2 and 3 in each of these variables.
What I did first was to create bins for each variable. Thus I was able to create a graphic shown below.
However, the problem is that always one of variables is automatically picked as a filter. In the example below this is "Bajo conocimiento..." (the blue one). So, the values for "Bajo conocimiento..." are correct, however, for instance, the COUNT("Exceso de...") for the values 1, 2 and 3 are the intersections of "Exceso de..." with "Bajo conocimiento...". As a result, the values of "Exceso de..." are lower that they should be.
How can I count the occurrences of 1, 2 and 3 for each variable independently and get the resulting chart?.

You will have to create a table calculation for every one of your columns.
Create a calculated field with the following formula and call it eg [ExcesoCOUNT]:
{fixed [columnname]: COUNT([columnname])}
if you drag the newly created field on your dashboard and turn it into a AVG() rather than a SUM(), you will get the count of each value.

Related

How to filter one source by clicking and filtering a bar chart from another source in Tableau?

I used an Apriori algorithm to view the frequent relationships in the dataset and I want to do a dashboard to better visualize this data but I don't know how to do this filter.
This is the bar chart that I created to show the support (amount of times something happend) and the confidence (probability of B happening given A) of these associations:
Apriori Chart
Next to it on the dashboard, I'll have a table with the full dataset used in this Apriori analysis where I have more information such as ID, Income, Hours Worked, etc:
Table from different data source
How can I create this relationship? The two data sources don't have a column in common that I can use for that.
I would need some way to:
Split the values in the antecedents columns by comma and filter only those columns with value equal to 1 in the other dataset
**Dataset A**
'Age Range <=30, Joblevel 1, Maritalstatus Single'
->
'Age Range <=30'
'Joblevel 1'
'Maritalstatus Single'
**Dataset B**
'Age Range <=30' == 1
'Joblevel 1' == 1
'Maritalstatus Single' == 1
Clicking this would filter the table next to it
Is there any way I can do this in Tableau?
You can download the tbwx i used in this example here https://community.tableau.com/servlet/JiveServlet/download/1083124-384949/Apriori.twbx
Thanks in advance for the help!
I am not able to check your twbx on the machine I'm using but I think you should be able to do this. The fields in the 2 data sources need to match so manipulate the data sources the make this happen.
For data source 1 there's a function SPLIT which will mean you are able to split the comma separated string to 3 fields.
Putting those 3 fields to the Detail shelf of your bar chart (or even Rows and hiding the header) will mean you can use them in an action filter.
Your second data source is a cross tab - post pivot. You should be able to pivot this data source. Highlight the measures and pivot them. This will give you the field Pivot Field Names and Pivot Field Values.
You only want to keep those with a value of 1 so create a calculated field
[Lookup1]: IF [Pivot Field Values] = 1 THEN [Pivot Field Names] END
Duplicate this field twice so you have Lookup1, Lookup2 and Lookup 3.
Then you should be able to action filter the table.
In the action filter set it up so SplitField1 = Lookup1, SplitField2 = Lookup2, etc.
Fingers crossed this works, I haven't been able to test so I am pulling it out of my head.

SSRS Grouping Summary - with Max not working

This is the data that comes back from the database
Data Sample for one season (the report returns values for two):
What you can see is groupings, by Season, Theater then Performance number and lastly we have the revenue and ticket columns.
The SSRS Report Has three levels of groupings. Pkg (another ID that groups the below), venue -- the venue column and perf_desc -- the description column linked tot he perf_no.
Looks like this --
What I need to do is take the revenue column (a unique value) for each Performance and return it in a separate column -- so i use this formula.
sum(Max(Fields!perf_tix.Value, "perf_desc"))
This works great, gives me the total unique value for each performance -- and sums them up by the pkg level.
The catch is when i need to pull the data out by season.
I created a separate column looks like this
it's yellow because it's invisible and is referenced elsewhere. But the expression is if the Season value = to the Parameter (passed season value) -- then basically pull the sum of each of the tix values and sum them up. This also works great on the lower line - the line where the grouping exists for pkg -- light blue in my case.
=iif(Fields!season.Value = Parameters!season.Value, Sum(Max(Fields!perf_tix.Value, "perf_desc")), 0)
However, the line above -- the parent/header line its giving me the sum of the two seasons values. Basically adding it all up. This is not what I want and also why is it doing this. The season value is not equal to the passed parameter for the second season value so why is it adding it to the grouped value.
How do I fix this??
Since your aggregate function is inside your IIF function, only the first record in your dataset is being evaluated. If the first one matches the parameter, all records would be included.
This might work:
=IIF(Fields!season.Value = Parameters!season.Value, Sum(Max(Fields!perf_tix.Value, "perf_desc")), 0)
It might be better if your report was also grouping on the Venue, otherwise you count may include all values.

Tableau: Selecting attribute levels and get and intersection instead of a union

I'm having some texts and for each text I'm having some tokens attached to it in a single column. The data looks like
Text_ID, Token
1, energy
1, debit
1, flat
2, energy
2, house
3, energy
3, debit
I created a metric according to countd(Text_ID) to count the numbers of distinct texts/text_ids. Now putting everything in the obvious way on a worksheet and selecting/filtering some tokens gives me essentially a union.
I'd like to select energy and debit and get the proper count 2 instead of 3 here. Of course I'm having a lot of tokens, hence the approach described here is not scalable.
Any suggestions on how to proceed here?
I'd assume that I need to create two parameters here, but I don't know how to use them to filter properly.
It seems like you want to identify the Text Ids that have at least one data row containing one specified token, “energy” in your example, and also have at least one data row containing another specified token, “debt” in your example. If that is the problem then I’d suggest using a set as follows.
Define two parameters to allow users to specify their tokens of interest, called for instance, token_1 and token_2
Define a set based on the Text Id field called Selected_Texts using the condition MAX([Token] = token_1) and MAX([Token] = token_2)
You can use the set in many different ways. If you want to count the number of distinct text ids that are in the set, create a calculated field called Selected_Text_Id as if [Selected_Texts] then [Text_ID] end Which holds the text id for matching texts and is null for others. Then you can plot COUNTD([Selected_Text_Id]) to answer your original question.
Create 2 paramter fields for selecting the required values and create a formula and add below code:
{ FIXED [Text ID]:
SUM(IF [Token] = [Parameter 1]
or [Token] = [Parameter 2]
THEN 1
ELSE 0
END)}

Show 0 for values with missing data

I have a dimension I am showing in a text table that can have one of 3 possibilities "A", "B", or "C" and I want at all times to have A, B and C shown in a text table even if one of them has 0 occurrences. The issue is that I am filtering this based on date, so it is possible that for example B may not exist, but I still want to have a 0 printed for B.
I have gone to Analysis -> Table layout -> show empty rows which will show "B", but in the count display it shows a blank. How can I get it to display a 0?
This problem is very famous among tableau users and I still did not see a generic tableau-only solution. All proper solutions start with injecting rows to your data which I assume you do not want this.
Below method will only work if you have a Date Dimension on the measure and no-data dates are not completely filtered-out; so you will be seeing zeros even though that date has no data as you may see on below screenshot.
When you filter out the no-data dates, unfortunately you will keep on seeing NULLs.
If you are using the SUM of Number of Records as your occurrences, then you may create a calculated field as below and use it in your pane:
ZN(LOOKUP(SUM([Number of Records]),0))
You can leave the Default Table Calculation as Automatic so the Results are computed along Table (accross).

Get 2nd Value in Dataset in Reporting Services

This seems to be a very simple question, but I am trying to get the 2nd value in a dataset to display as a matrix's header value.
In this report, lets say that I have 2 datasets. In Dataset1, I have a query that pulls down 3 values for a parameter dropdown selection. In Dataset2, I return a result set and have bound it to my matrix.
Within the matrix, I have my repeating columns, and then 3 additional grouped columns to the right that have aggrigate values that I want to display. On the header of those 3 columns, I want to display the 3 values displayed in my Parameters dataset. Within the context of the matrix (and its dataset), I can get the first and last values of a different dataset (Dataset1 in this case) by using:
=First(Fields!DateDisplay.Value, "Dataset1")
=Last(Fields!DateDisplay.Value, "Dataset1")
I need to get something like:
=Second(Fields!DateDisplay.Value, "Dataset1")
How do I pull this off without violating the scoping rules on aggregate columns?
For SSRS 2008 R2, you can do this if each row of your dataset has an identifier column by using the LookUp() function.
=LookUp(1,Fields!Row.Value,Fields!DateDisplay.Value,”Dataset1”)
=LookUp(2,Fields!Row.Value,Fields!DateDisplay.Value,”Dataset1”)
=LookUp(3,Fields!Row.Value,Fields!DateDisplay.Value,”Dataset1”)
If you do not have an identifier column you can use ROW_NUMBER() to build one in.
Query:
SELECT ROW_NUMBER() OVER(ORDER BY DateDisplay) AS Row, DateDisplay
FROM Dates
Results:
Row DateDisplay
--- ---------
1 June 1st
2 March 12th
3 November 15th
Here is a link to a similar thread in MSDN Forums: Nth row element in a dataset SSRS
If you are using SSRS-2012 or 2014 then one has to use below expression.
=LookUp(AnyRowNumber, Fields!RowNumber.Value,Fields!DisplayField.Value,”DatasetName”)
I have tried above it was not working in my case.