I've just started using Quicksight and I can't for the life of me figure this out.
Let's say I have a table that goes like this :
date
country
color
nb_sales
10-11
USA
Black
10
10-11
USA
Blue
5
10-12
USA
Blue
20
10-11
UK
Black
10
10-12
UK
Black
15
10-11
UK
Blue
15
What I want is the average daily number of sales by country, preferably in a pieplot :
country
avg_nb_sales
USA
17.5
UK
20
So I need first to group by date, country and sum the ratings and then once this aggregation is done I need the average by country. I thought I should be using avgOver(sum(ratings), country) but I can't get it right.
So how do I achieve that ?
I thank you for your time.
I have managed to get the result expected though not sure that it is the best way to do it (especially if you have some dates when you get sales only for one country):
avgOver(sum(sales), [country])/distinct_count(date)
Related
I have a file, and I wish to sort by the second column, the problem is that the data columns contain spaces. How to sort alphabetically by the second column, then by the third (Numeric) column?
I tried sort -k44,62 and do not get the expected answer. i.e. Alphabetical sort based on column 2.
Starbucks Seattle 291,000
Costco Wholesale Issaquah 245,000
Microsoft Redmond 134,944
Barrett Business Services Vancouver 115,746
Nordstrom Seattle 74,000
T-Mobile Bellevue 51,000
The Hotel Group Edmonds 35,330
University of Washington Seattle 26,110
Fortive Everett 26,000
Paccar Bellevue 25,000
Providence Health & Services Renton 20,640
Expedia Group Bellevue 20,075
Savers Bellevue 20,000
Alaska Air Group Seattle 19,214
Expeditors Seattle 17,400
MultiCare Health System Tacoma 17,000
Esterline Technologies Bellevue 12,000
Recreational Equipment Kent 12,000
Carrix Seattle 11,000
Labor Ready Tacoma 10,000
SSA Marine Seattle 10,000
Nash Holdings Seattle 10,000
Trident Seafoods Seattle 9,000
Eddie Bauer Bellevue 8,000
Chief Seattle BSA Seattle 7,785
Laird Norton Co Seattle 7,500
Windermere Real Estate Seattle 7,000
Slalom Seattle 7,000
PeaceHealth Vancouver 6,690
Itron Liberty Lake 6,200
TrueBlue Tacoma 6,000
Nintendo Redmond 5,944
JACK FROST FRUIT Yakima 3,000
YAKIMA REGIONAL MED CARDIAC CENT Yakima 3,000
NORTH PUGET SOUND CENTER FOR SLEEP DISORDERS Everett 2,500
Chose a field delimiter that does not occur in the data and work on field 1:
sort -t '|' -k1.47,1.62 < f
To also sort numerically on the 3rd logical field:
sort -t '|' -k1.47,1.62 -k1.63n < f
Unfortunately the sort will break if all values are not in the range from 1,000 through 999,999.
I want to generate a report in obiee , by grouping countries and showing there cumulative sum
I tried creating bins like for china I created a bin which contains singapore, taiwan and china. another bin for japan containing some countries. using pivot table i can show the sum of customers in a region by dates for these two bins. but when I need a cumulative sum for every bin it is giving weird values
Number of employee by region and date where china and japan are bins
china japan
01-Nov-18 1 3
02-Nov-18 2 4
03-Nov-18 1 1
04-Nov-18 2 5
05-Nov-18 4 7
06-Nov-18 5 7
where as result i want( how can I achieve this)
China Japan
01-Nov-18 1 3
02-Nov-18 3 7
03-Nov-18 4 8
04-Nov-18 6 13
05-Nov-18 10 20
06-Nov-18 15 27
The measure has to be a running sum in that case. RSUM(YourMeasure)
Make a duplicate layer of the measure column. Click on the duplicated column and select the option 'Display as Running Sum'.
Alice lives in Russia(GMT+7). Bob lives in Alaska(GMT-8). They are relatively close, and less than 200 miles apart. https://www.google.com/maps/#55.5067319,-173.8489655,3z
Alice and Bob should meet at noon based on an average of their Time Zones so both people are inconvenienced as little as possible. If we average GMT+7 with GMT-8, we come up with GMT-0.5.
This does not work because calculating noon based on GMT-0.5 would be closer to midnight for both, rather than noon because the time zones are calculated linearly instead of circularly.
Does anyone know of a library which can solve Alice, Bob's problem, and also allow Charlie and Dave to join the meeting?
Your GMT-0.5 average is wrong, because to get the time difference we have to take into account the 24 hour cycle and the fact that GMT is half way between both ends of the range.
GMT+0700 is 15 hours ahead of GMT-0800, but as 15 is greater than 12 (more than half way round the Earth) the shortest time difference is actually 9 hours, but on different days.
That maths is pretty easy. In pseudo code:
offset = abs( 7 - -8 )
if offset > 12 then offset = 24 - offset
Gives offset == 9.
So the closest times to local noon for both parties would be 4.5 hours before noon for Alice in Russia (07:30am) and 4.5 hours after noon for Bob in Alaska (16:30pm) but on the previous day because Russia is in the future!
This half way point would be an imaginary time offset we can call GMT+1130, so Bob and Alice would arrange to meet at 00:30 GMT.
For comparison: timeanddate.com has a meeting planner. It rounds to the hour and gives the best overlaps for Krasnoyarsk and Anchorage as 8am/5pm.
See https://www.timeanddate.com/worldclock/meetingtime.html?iso=20180724&p1=372&p2=18
Academic side point: these two timezones are not a mere 200 miles from each other. They are thousands of miles apart. The eastern point of Russia is actually 12 hours ahead of GMT.
I'm adding table rates shipping method to a Magento install.
My rates are divided per weight in 6 different ranges 0-3 | 3-6 | 7-10 | 11-25 | 26-50 | 50-100 always the same in the whole Italy except for 3 regions.
In these regions prices for same weight ranges are slightly different. So It would be super good being able to add region codes into the right field, but where I can find those codes?
Headers into CSV are:
Country,Region/State,"Zip code","Weight (and Above)","Shipping Price"
I need to undrstand what I must add to the "Region/State" filed.
Adding different prices using Zip Codes would mean adding 7056 lines to my CV manually!
TNKS.
Go and look at this table in your magento database;
select * from directory_country_region
This reveal all the regions currently in your store;
1 US AL Alabama
2 US AK Alaska
3 US AS American Samoa
4 US AZ Arizona
5 US AR Arkansas
6 US AE Armed Forces Africa
7 US AA Armed Forces Americas
8 US AE Armed Forces Canada
9 US AE Armed Forces Europe
10 US AE Armed Forces Middle East
etc. Column C is the region code. You can add to this if required.
I am trying to model the following problem: a set of people (teacher of school in the reality) must reach the office each one at different hours (i.e. people 1 enters at hour 2 and exits at hour 7, people 2 enters at hour 4 exits at hour 6 and so on). These times changes depending on the day of the week following a given timetable.
In order to reach the office people with same starting hour meet in a common place and share a car. Similarly when they have to come back from office they will sort in the cars of drivers leaving at given hour to reach the common place near their houses. The problem is how to assign a driver and a crew for each turn so that:
all people can find place in a turn (both in departure and return)
in each turn there is a maximum number of persons (due to the limited car places)
minimize the total number of cars used
each person should drive the car the same number of the other (or make as even as possible the use of each car/driver)
The input therefore is a table like:
Mon: Andrew 1-3 (hour of departure-return), Bill 2-5, Cindy 1-7 ...
Tue: Andrew 2-7, Bill 1-6, Cindy 2-4 ...
Wed: ...
while the output should be
Mon: Departures: hour 1 (driver Andrew, crew: Cindy, Steve), hour 2 (driver Bill, crew: Steve, Frank)... Returns: hour 3 (driver Andrew, crew: Jim, Lisa), hour 4 (driver Mary, crew: David, Pete)...
Tue: Departures hour 1 (driver Bill, crew: Richard, Dan, Pete), hour 2 (driver Andrew, crew: Cindy, Bob) ...
Wed...