partitioning by more than 1 field in tableau - tableau-api

I Can't figure out how to partition by more than 1 field in tableau.
Data landscape - I have 2 dimension fields: id (string) and platformtype (str). I have 2 measures: total_usage(float) and month (int). Using Tableau Desktop 10.3.3 on a mac.
Goal - I am trying to create a view with a single bar chart that shows the top N ids by total_usage in a given month. I'd like to filter by month and by platform_type, and to be able to change N (say, in the range of 5 - 25 in steps of 5).
Can anyone help?

After you you place month on the filter shelf, add it to the context. Then you will first filter by month before applying other filters, such as the top N filter on ids.

Related

Tableau - Toggle between 2 measures by single select filter on one basic text grid

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.

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

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

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.

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.

How do I chart a calculated percentage value in Crystal 9

I am using Crystal 9 and have created a report showing calls logged by users, time taken to close the call, Solved with (allocated a value to the latter field depending on time taken eg. 1-59 mins = < 1 hr = 1), 60-239 mins = < 4 = 4. I have then grouped the results by users and got totals for each of the Solved values
Solved1 = solved in less than 1 hour
eg group total shows (when record data hidden)
User1 (Total Calls= 74) (Solved1 = 42) (Percentage1 = 56.76)
User2 (Total Calls= 17) (Solved1 = 2) (Percentage1 = 11.76)
Total Calls and Solved1 are obtained using Running Total Fields.
Percentages are Formula fields and calculated as follows:
Percentage1 = Solved1/Total Calls * 100
My problem is that I need to graph the percentage values for each user for each Solved value eg. 56.76 and 11.76 on one chart. This would be easy except that Crystal doesn't let me select this field in the chart option because it's calculated from two Running Totals.
Since some formulas are accepted by the Chart expert and running totals are also accepted, is there a way I can calculate the percentage which it would find acceptable? Or can I put the total and Solved value in the chart and have the chart calculate the percentage somehow? I was looking at using count and I can get the count to count all the records for a single person but not where say the value in a specific field = '1'
eg count (call_id, )/count (call_id, closedby) * 100
Does anyone know how I can write that fomula or any other way of graphing a percentage?
You can do this using Crystal formulas.
Set up a formula for Solved1 - something like
if {myTable.timeTaken} < 60 then 1 else 0
Next, set up a formula for Percentage1 - something like:
100*sum(#Solved1,{myTable.closedBy}) / count({myTable.call_id},{myTable.closedBy})
Drag and drop the formula for Percentage1 onto the report layout, then you should be able to add it from Report Fields onto your graph in the Data tab of the Chart Expert. (You may then want to remove the Percentage1 formula item from the report layout.)
I ran into a similar issue trying to graph On Time Delivery percentages.
I have three percentages to display: On Time, 1-3 days late, and over 3 days late.
I was in need of displaying zero percents as well, i.e. when there were no records that were "1-3 days late" I still needed to show 0% as one of my bars. The above did not address that. I ended using this resolution with a twist.
I created 4 formulas:
one to return 1 if the record was on time else 0
one for the 1-3 days,
one for the over 3 records.
one for each record returning a value of 1.
With that I was able to create my percentage fields using the Sum of one of the first 3 formulas divided by the sum of the "1" formula. Crystal would not work if I used the Count(...) function on a key field. It only worked when using the Sum(...) function in my percentage formulas.