Arrange filter values in tableau - filter

I Have Filter Values (dimension) in Tableau - that I want to arrange in ascending order.
The values in the quick filter are currently ordered alphabetically:
03 to 05-Jun-2015
06 to 10-Jul-2015
08 to 12-Jun-2015
13 to 16-Jul-2015
15 to 19-Jun-2015
20 to 24-Jul-2015
22 to 26-Jul-2015
27 to 31-Jul-2015
29 to 03-Jul-2015
In the list above, values are ordered alphabetically, not chronologically. I want them to be in this order:
03 to 05-Jun-2015
08 to 12-Jun-2015
15 to 19-Jun-2015
06 to 10-Jul-2015
13 to 16-Jul-2015
20 to 24-Jul-2015
22 to 26-Jul-2015
27 to 31-Jul-2015
29 to 03-Jul-2015
Is there a way to make the above filter values display in the desired order?

One approach is to apply a manual sort order from the sort panel (which you can bring up by right clicking on the dimension you wish to sort, either on the data pane to set a default sort order, or on a shelf to set a sort order for one worksheet)
If you don't want a manual sort order, you can apply a dynamic sort based on the values in the data from the same panel, or use the database default sort order (usually alphabetic order).
In that last case, you probably want to use a standard easily sorted convention for your field values -- say ISO 9001 dates like YYYY-MM-DD, perhaps following by a duration length in days, say YYYY-MM-DD (n)
Alternatively, if you could change the data type of the field from string to date, say called start_date, then you would get sorting by default and many options for filter controls.

Related

How to sort values for a control

While creating a control, you need to setup control values (specific or linked from a date set field).
I've created a control containing month names (Jan, Feb,....). The problem is that control values seems to be sorted in an alphabetical order (Apr, Aug, Dec,....) - this is not user friendly at all.
I've tried both setups (specific values, values linked from db), but with the same result
Any idea how to have list elements sorted i.e. by month_id?
One approach you can take is prefix month name by month number like
201901 - Jan
201902 - Feb
What you're observing is correct - QuickSight will not allow you to define a sorting logic for values populated for a Control. They will be always sorted in an ascending alphanumeric order.
For your use-case, I recommend you work-around this by prefixing/replacing month names with month numbers
01 - Jan
02 - Feb
03 - Mar

Tableau Dashboard - top 15 filter not sorting correctly

sorted correct but not top 15
sorted incorrectly but top 15
I have this dashboard and I want to show the top 15 stations on current year (2018) for delays/departures.
If I have the sort in the Columns, it sorts in the correct order, but it shows all of the stations.
If I put the Station in the filter for top 15, it somehow gets sorted incorrectly.
My formulas are
2018 rank = if [Year] = 2018 then [Delay Measure] else 0 end
2018 ranks = [2018 rank]/departures_count
Make [Month] a context filter, by right clicking on it on the filter shelf and choosing “Add to Context”
Then Tableau will first apply the [Month] filter and then apply the top 15 stations filter upon those results. Otherwise, the filters are independent and you are filtering to the top 15 stations over all months, then just showing the data for a selected month.
You're nearly there, you need to combine approaches
Firstly you filter to get the top N from the column pill Station. So click --> Filter --> Top N field
Then once you have done that you'll only be showing the top n results in your report
Next we can sort these top 15:
Click on column pill --> Sort --> Descending --> Your sorting field
Instead of choosing a number to filter the number of stations, it's a nice idea to give users the option by using a parameter. Then in the Top N you can change it to your newly created integer parameter:

groupBy in laravel function similarly to distinct?

My records in 'answers table':
**id question_id answer**
20 12 app/Http/routes.ph
21 13 uri
22 13 closure
23 14 controller
24 15 class name
25 15 App\Http\Controllers
26 16 for displayh
My code to retrieve data:
$qas= DB::table('answers')
->groupBy('question_id')
->get();
dump($qas);
}
I get only 5 records instead of 7; where the other 2 records?
It works similarly to distinct function which is not my intention.
How to write code to get all 7 record which are grouped by 'question_id'?
Understand the concept of GroupBy, its mean that, it will consider same items as one, eg 14, 14-> 14 | 13,13-> 13 if you want to get all answer, then you have to write this
DB::table('answers')->get();
Edited
distinct and group by will do same action in your case.
If You can explain your problem in more details, then may be there is possible solution are.
You're talking about result with 7 rows, but that's not grouping. Maybe you're talking about ordering instead of grouping? If so, you'd want to use ->orderBy('question_id', 'asc'), that will give you 7 rows, sorted by question_id.
In SQL, GROUP BY clause is useful when you need to aggregate the result in a sort of way for example for SUM or AVERAGE of data.
Your case is different, you don't need to aggregate data using some function, you simply need a different data structure other than a simply and flat result list.
For your need, you should avoid GROUP BY, and reorder data in your code in a programmatic way.

How to sort in filter without using Dynamic Ranking in Endeca?

We are using Endeca to fetch and display records in frontend as a datagrid. In that datagrid, we have 10 columns and we display data sorted in table on the basis of 2 columns (say X and Y). For this, we use Endeca.stratify(collection()/record[not%20(X)])||X|1||*,Endeca.stratify(collection()/record[not%20(Y)])||Y|1.
We can also apply filter on the columns where we display data sorted asc/desc. We used Dynamic Ranking in Endeca and created dimensions for each field with selecting dynamic ranking and set maximum dimension value to return as 20 as per the requirement. Since we know that dynamic ranking is the relevancy ranking, it fetches most used records and does sorting on that data.
However, we need to select 20 unique values and sort them in asc/desc order. Example: if we have date as the column, then we need to fetch 20 unique dates with most recent at the top. i.e. in descending order.
Is there any other way to do sorting on filter apart from dynamic ranking? If we disable dynamic ranking, then we won't have option to set maximum dimension value as 20 from developer studio.
Please suggest for the ranking.
We finally found a solution!! I removed/unchecked "dynamic ranking" for the properties in dimensions from the pipeline using developer studio. I did not want it to remove since we had already selected an option as sort "alphabetically" instead of "dynamically" in dynamic ranking tab in dimensions.
Also, if we uncheck dynamic ranking then the option for giving maximum limit for displaying the dimensions (which was set 20 for us as per the requirement) was also gone.
So, I handled this in java to display only 20 values by putting a check on results obtained and created a counter which would add values only till the 20 are received. Now this is working as required!!!!!

How do you parse a HTML table representing time?

I am attempting to parse this HTML table representing a year's worth of temperature data, provided by an Australian government website.
This table is set up in an unusual way: the columns are months, and the rows are days of the month (so the first row's cells are JAN 1, FEB 1, MAR 1). Each cell contains a number if there's data recorded for that day, an empty cell if no data was recorded, or a cell class notDay if the day does not exist (eg Feb 31st).
My intent is to build a database full of this data in the format
DATE RAINFALL MAX TEMP
2015-02-07 35 31
2015-02-07 40 17
My question is: what would the simplest or most efficient (in terms of programmer efficiency) way to parse the table to get the data into a usable format?
I'm personally using Ruby with the Nokogiri library, but general non-language-specific algorithm/approach advice is welcome if it makes for a better discussion. I'm not looking for someone to write the code and solve the problem for me, but for advice about the approach to take.
I wonder if you can:
Take all the cells in the order they appear:
Use Array#flatten if you've got an array-of-array situation.
Discard any notDay cells with Array#reject
Iterate over all the relevant dates using a date range:
(Date.new(2014,1,1) .. Date.new(2014,12,31)).each {...}
And go from there...?

Resources