Sorting Data by Latest Date, selecting top 10 and charting (v. 10.0.1) - tableau-api

This is the data table that I have created
I need to sort the data by 'April2017' in descending order and then select the top 10 projects.
When we select top10 basis April2017, the output should be
Instead what I get is
Here is what I've tried out so far,
Created a calculated field
Calculation1 = iif([Year_Month]=MAKEDATE(2017,4,1),[Claim Count],0)
Sorted Projects based on 'Calculation1'
Drag Project to Filter and select Top10 based on sum([Calculation1])
I am unable to understand how the top10 here is being derived.
Where am I going wrong?
The chart that I am trying to get should be similar to
Please help me with this problem.

You can filter to a selected portion of data in a calculation and use as desired. So create a calculated field called, say April_2017_Foobars, defined as:
if datetrunc('month', [Year_Month]) = #04/01/2017# then [Foobars] end
This field return [Foobars] for the April 2017 rows and null for other rows. Nulls are ignored by aggregate functions, so if you aggregate with SUM() or AVG() etc, the effect is to filter to April 2017 for that field alone.
Then you can use April_2017_Foobars for sorting and defining top filters for your Project field. This is a very general technique that is useful in all kinds of situations.
You can generalize it a bit to use a parameter for the special month rather than hard code it - or use an LOD calc to find the last month in your dataset if you always intend to use the latest month.
P.S. You can use the makedate() function instead of a date literal if you prefer and your data source supports that function. Might avoid any confusion about date literal formats being different in various countries.

create Calculation1 field: iif([Year_Month]="April 2017",[Number],0)
sort Project in descending order on Calculation1 Sum
drag Project to filters, and do Top > By Field > Top: 10 by Calculation1 Sum

Related

Tableau Target Vs. Actual - Can not get totals to show correctly

I am having trouble showing the correct totals in my tableau worksheet.
I have supervisors that are part of specific zones that need to complete a certain number of tests in different categories. For example, supervisor 15716 must complete 8 tests in category 1. I need to show the target, which is a number stored in the database and show the actual number of tests in that category that have been completed within a date range. I have it working, but Im not sure if I did it correctly because I can not show any totals.
System target - number stored in database
CountOfSheetID - calculated field
Percent Compliant - calculated field
Try this approach -
First define a calculated field called [Within Date Range?] as
[Date] >= [MyStartDate] AND [Date] <= [LastSelectedDayOfMonth]
and put that new field on the filter shelf, only including data where [Within Date Range?] is True. (You could also just filter the [Date] field if that is flexible enough for you)
The you don't need the CountofSheetId calculated field at all. If you want to know how many records have a non-null value for [SheetID] within your date range, you can simply drop [SheetID] on a shelf and choose to treat it as Measure with the aggregation function COUNT()
Then just build your visualization to show the counts you want (not percentages, the actual counts)
Finally, you can convert counts into Percentages by clicking on the pills for your Measures and choosing Percentage under Quick Table Calcs. You'll want to experiment with the "Compute Using" setting to tell Tableau how to compute your percentages -- i.e. define percentage of "what".
Percentages are implemented as table calcs in Tableau. Read the help to understand table calcs, especially the description of partitioning and addressing.

How to filter by current month automatically on pivot table google sheets?

As a data analyst, I would like to see the report in a pivot table automatically for the current month, so that I can take a look at it and don't have to change the date filter manually.
This is the formula to show the first day of the current month. (Which is the criteria I need, first of the current month)
=EOMONTH(today(),-1)+1
It works when I put this formula in any cell.
But when I put it in the pivot "filter by condition" option it doesn't work.
This is what I tried.
Text is exactly =EOMONTH(today(),-1)+1 (In formula box)
The date is exactly =EOMONTH(today(),-1)+1 (In formula box)
Here a screenshot of the options
Any help will be greatly appreciated.
I've never had great luck with the pivot table filter criteria in Sheets, I typically filter the data first if it's more advanced or use aggregating functions. In the Sheets pivot tables are better for quick analysis than dashboards.
There's probably a few ways to do it, but one of the easier ways would be to duplicate the data tab, clear the data and use a filter function to retrieve data. Update the Pivot table data source to the new tab. This will always only be the current month's data.
Basically you filter the data before the pivot table, with the [filter function][1].
=Filter(data , [date col]>=EOMONTH(today(),-1)+1 , [date col]< date(year(today()), month(today())+1,1)
You can also add a month column to the data and then filter on that column, however each month you would need to update the month filter in the pivot table.
=date(year([date cell]),Month([date cell]),1)
If you're using it for a 'dashboard' of sorts, I would generally recommend to create it yourself with aggregating formulas (sumifs, countifs, ect) and then you can use the more complex filters.
try custom formula:
=MONTH(A2)=MONTH(TODAY())
where A2 is first cell of column containing valid dates
You can try to Filter by a Custom Formula:
=month(DatePurchase)=month(TODAY())
Where DatePurchase is the Field Name.

How to show previous value based on selection from quick filter in Tableau

I like to show the previous period value with difference based on the period selected from the quick filter in Tableau.
For example:
If I select 2019 from quick filter I would like to see the value with the difference compared with previous period (i.e 2018)
(means 2019 (from quick filter) vs 2018).
You can't access a quick filter value directly in tableau instead use parameters where you can access the parameters in calculated fields.
For this requirement LoD serves the purpose, where use a Fixed LoD which will bypass the filtering and get you the values.
For E.g
{Fixed :Sum(if year = 2018 then sales end)}
In worksheet you have 2019 value then use a calculated field to find the difference
Edit-------------------------------------
If quick filter is a single value selection then you can subtract 1 from year field. like below:
{Fixed :Sum(if year = [datbasefield.year]-1 then sales end)}
Instead of using a filter to select your period, use a parameter. Then you can use a calculated field to filter to both the year selected by the parameter and the prior year.
If you then want to calculate the difference between two years, you can use a Quick Table Calc (right click on the green measure pill on whatever shelf you are using).
If you then want to hide that first (empty) value, use the hide command or a table calc filter.
So in a nutshell, read about parameters and table calculations in the on-line help

Use a Level of Detail Expression in Tablaeu on 1 of 2 forms of a date variable

In Tableau a Level of Detail Expression allows you to create a calculated variable that is affected by none or only some of the view level filters.
I have a view that has 2 filters based on the same column -- a YEAR(Date) filter and a MONTH(Date) filter.
If my Level of Detail Expression is:
{EXCLUDE [Date mdy]: SUM([count.Attrition])}
that won't work because it would remove both date filters. I only want to remove the MONTH date filter.
However, this
{EXCLUDE [MONTH(Date mdy)]: SUM([count.Attrition])}
is an invalid expression and this:
{EXCLUDE MONTH([Date mdy]): SUM([count.Attrition])}
is allegedly valid but doesn't actually work.
Hack-R, how about using FIXED, I think that should help solve this:
{FIXED [Year] : SUM([count.Attrition]) }
Using FIXED is basically forcing Tableau to calculate aggregate measure at specific level - in this case on Year
[Year] is just a simple calculated field which returns Year value.
YEAR([Date mdy])
Creating a dedicated calculated field is probably not really necessary in Tableau 10, but it's just my personal preference to keep things organized.
You might be wonder why EXCLUDE didn't work - I think the main use-case is different with INCLUDE/EXCLUDE and probably best explained in this (a bit lengthly) article.
Hope this helps.

How can I sum up values by date(month) in report builder 3.0 graphs?

I'm trying to sum the data points by Months instead of individual days. The data is originating from an SQL Query so I'm thinking this may be the only way to do that. However, I would much rather do this inside of Report Builder 3.0. Any hints on how to do this?
For example, I want to see the number of tickets for the Months of December and January as only two seperate data points.
can you create a new field ( calculated perhaps) onthe dataset and group by that?
else you should be able to create an expression on the graph's group that groups by Month of a certain field.