How to sort values for a control - amazon-quicksight

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

Related

How do I subtract two rows from a POWERBI custom table?

Project
Cost
January
323
Feb
323
I have a table as followed seen above which ROW is month (filtered by a certain project) and values are cost of the project. I want to calcuate the difference between two months, but I am having trouble.
How do I subtract two rows from each other.
In the code I wrote:
Variance = [Cost] - CALCULATE([Cost],PREVIOUSMONTH('Month'[Month))
I get the following error, A column specified in the call to function is not of type date.
Is there a way to manual subtract two months?
The best way to do it is to replace your month with an actual Date value. The first of the month for example. The you should be able to do something like this assuming your month dates are unique: If they are not unique you should create a Dates table (See Microsoft's Guidance on date table) and join.
variance = [Cost] - Calculate([COST],(PARALLELPERIOD(Month[Month],-1,Month)
You can use EARLIER function here but, only when the Months have an Id. Such as
1 Jan
2 Feb
3 March
...
Link for details
However, I would suggest creating a date table and then having a relationship from the date table to your table. By using date table you can easily achieve using in-buit date functions.

Show value from last day of the given month - SSRS Report Builder

In a Report Builder table I have to show the value from the last day of the given month, when the month is not expanded.
When the month is expanded, the dates have to show the specific value for that day.
Example is January with values 1 to 31 (same as the day numbers):
When January is expanded, it has to show value 1 on Jan 1.... value 15 on Jan 15... value 31 on Jan 31.
When contracted (and the table only show one row for January), it should show the last day's value of 31
Some months do not have values on all days, so the formula just need to take the last value of that given month
When I use the formula "Last()", then it works half of the time, while for some months, the value extracted is the 3rd or 4th last day of the month - do you know what is wrong here?
Hope above makes sense, and thanks for help.
I think I fixed it my self:
Using Last () formula
Learning how to make a sort order in my Union All dataset, so it came out in the right way
How to give points to my self?

Arrange filter values in tableau

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.

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...?

Need to set up a customised date range validator in Ruby On Rails

I have the following model which corresponds to teh following table:
PriceAvailability
ID| PRODUCT_ID| VALID_FROM|VALID_TO|PRICE
Basically the table stores prices of a particular product between a specific range of dates. Like a product may cost 10 dollars between 1st Jan 2012 to 3rd May2012 and 12 DOllars from 3rd of May to end of June etc. Thing is that I need to set up a validator that:
Ensures that each record has a date range that doesnt overlap or conflict with another date range for that specific product, i.e you canot have two rows that have a date ranges 1st of Jan 2012 - 1st March 2012 and 1st of Feb 2012 to 1st April 2012 respectively for product ID 1.
I got the idea of setting up validators and even set up a simple validator for the start date however I'm stuck with implemnting this kind of check. How can I do it?
let me know if this works for you:
validate :ensure_unique_date_ranges
def ensure_unique_date_ranges
date_ranges = (products.price_availabilities - [self]).map{ |pa| (pa.valid_from.to_i..pa.valid_to.to_i) }
self.errors[:base] << 'date range is invalid' if date_ranges.detect{ |dr| (dr.to_a & (valid_from.to_i..valid_to.to_i).to_a).empty? }
end
One thing to watch out for is date.to_i. If ranges are big then performance might go down. Try and see if it's acceptable.

Resources