Hiding all columns in Tableau graph whose value is below a threshold - tableau-api

I am using a Tableau worksheet having 10 factories (entries) and 10 measure values for each factory/entry. There are a total of 100 columns in my Tableau worksheet.
I want to hide all columns whose value is zero and only show non zero values. But since each column is a different measure value, I can't filter or sort them. How do I go about this?

If you have tableau prep, then melt your data in pivoting. In prep you can easily remove nil or zero values easily.
Ideally you should have 11 columns, 1 for factory_id and other 10 for measures.
Alternatively, break all 10 factories in 10 groups of data and Union them after adding an id field for each group.
This link will help https://www.tableau.com/about/blog/2018/4/how-perform-coordinated-pivots-tableau-prep-86661

Related

Tableau How to evenly split a Ranking Table into two

I am trying to evenly split a ranking table into two.
I tried to create a calculated field using rank to divide the data into two groups.
The problem with this approach is that there are too many entries in the first column because they are tie with rank 1.
I don't want to break the tie but display evenly in both columns.
So, desired output will look like...
25 states with Rank 1 are displayed in column 1, and the rest 12 rank 1 states and the other states from rank 38 to 49 are displayed in column 2.
In order to split your rows within a specif number (say 25) you can't rely just on rank due to same values for multiple rows.
Even though your Rank calculated field must be shown in the chart, you can add another calculated field based on rank_unique which will provide you a progressive number for rows having the same value for the specified metric.
Just use the specified function:
RANK_UNIQUE(SUM([Value]),'desc')
And then use the calculated field as a filter to "split" the results as you need (in this example 1-4, 5-8).

Pick group totals, grand totals and normal summarization in Tableau

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.

Sum two columns together in Tableau

In Tableau, I am trying to figure out how to sum up the percentages of two columns. I calculated the percentages using the percentages of command and used the table option, from the analysis menu. This generated the table shown below. I would like a column that sums the 4 and 5 columns together to show a total percentage of 59.76 which is 26.83+32.93 from columns 4 and 5. How would I create this calculated field?
How I generated the percentages:

compute difference between 2 ranked columns in tableau

I am trying to find the difference between 2 columns in tableau. The catch though here is that each column is ranked based on a value. The difference i need is between these 2 ranked columns
The rank is computed using the table calculations rank function. Attaching the picture for more information
I am assuming "current" and "prior" are calculated fields.
Just create a new calculated field, here I'll call it "Result". In this field just minus your one from the other so:
[Current - Prior]
Then pull this new field into your measures values on your sheet.

postgresql compute min value of columns conditiong on a value of other columns

can I do this with the standard SQL or I need to create a function for the following problem?
I have 14 columns, which represent 2 properties of 7 consecutive objects (the order from 1 to 7 is important), so
table.object1prop1, ...,table.object1prop7,table.objects2prop2, ..., table.objects2prop7.
I need compute the minimum value of the property 2 of the 7 objects that have smaller values than a specific threshold for property 1.
The values of the property 1 of the 7 objects take values on a ascending arithmetic scale. So property 1 of the object 1 will ever be smaller than property 2 of the objects 1.
Thanks in advance for any clue!
This would be easier if the data were normalized. (Hint, any time you find a column name with a number in it, you are looking at a big red flag that the schema is not in 3rd normal form.) With the table as you describe, it will take a fair amount of code, but the greatest() and least() functions might be your best friends.
http://www.postgresql.org/docs/current/interactive/functions-conditional.html#FUNCTIONS-GREATEST-LEAST
If I had to write code for this, I would probably feed the values into a CTE and work from there.