I am attempting to load some oil and gas production data into spotfire. This data is currently in a time series, ie one column has well name, another has production values (bbls) and then one column has months and another years( I also have a concatenate month/year column). I would like to create another calculated column that contains a day counter, I.e. May 1974 would be day 1 and then June 1974 would be day 32 and so forth.
In excel I would do this with an if statement and reference preceding cells, but being a bit new to spotfire I am unsure how to do this.
Could someone please point me in the right direction? Suggest some functions?
Thanks for the response scsimon.
I solved my problem by creating a case statement for the days in each month and then summing over the days per well for all rowIDs.
case [Month] WHEN "JAN" then 31 when "FEB" then 28 when "MAR" then 31 when "APR" then 30 when "MAY" then 31 when "JUN" then 30 when "JUL" then 31 when "AUG" then 31 when "SEP" then 30 when "OCT" then 31 when "NOV" then 30 when "DEC" then 31 end
Sum([c.Days in Month]) over (Intersect([Entity],AllPrevious([c.rowID])))
This gave me the desired response.
Related
I have long (multiple thousand lines and growing) list of data in Sheets which have a date and additional columns with data. Here's a simplified example of this list (=TAB1):
Date Number Product-ID
02.09.2021 123 1
02.09.2021 2 1
01.09.2021 15 1
01.09.2021 675 2
01.09.2021 45 2
01.09.2021 52 1
31.08.2021 2 1
31.08.2021 78 1
31.08.2021 44 1
31.08.2021 964 2
30.08.2021 1 2
29.08.2021 ...
...
Three remarks:
The date is formatted to European standard DD.MM.YYYY
There definitely is more than one line per day per product (could be a big number depending on the day)
(for the formulas below) In the European standard Sheets uses ; instead of , as in =IF(A;B;C)
In a different tab (=TAB2), I want to add up all the numbers for a unique date for Product-ID 1. So far I've done it like this:
Date Sum (if Product-ID=1)
=UNIQUE('TAB1'!A2:A) =ARRAYFORMULA(SUMIF('TAB1'!A:A&'TAB1'!C:C;A2:A&"1";'TAB1'!B:B))
02.09.2021 125
01.09.2021 67
31.08.2021 124
30.08.2021 1
29.08.2021 ...
...
This works fine so far. Here's what I want to do now:
For every month (here: August and September 2021) I need an additional line above the current date (in this case: above 02.09.2021) AND above a completed month to sum over the whole month for column B. Here's how it should look like:
Date Sum (if Product-ID=1)
September 2021 192
02.09.2021 125
01.09.2021 67
August 2021 125
31.08.2021 124
30.08.2021 1
29.08.2021 ...
Of course, the line for the next day (03.09.2021) should be added above 02.09.2021 and below the sum for the month when it's automatically added to TAB1 on the next day.
I tried to play around with s.th. like =IF(DAY(UNIQUE('TAB1'!A2:A))=1;...;...) but didn't get far.
Is there anyone with an idea how to realize s.th. like this?
You want to learn about QUERY().
in cell A1 of an empty tab.
=QUERY('TAB1'!A2:C,"select A,SUM(B) where C = 1 group by A")
it makes a very big difference whether your product ids are text or numbers. the above was written as if they are numbers, but you might have just been simplifying. If they are text you would write it like this:
=QUERY('TAB1'!A2:C,"select A,SUM(B) where C = '1XYZ' group by A")
note the single quotes.
if the IDs are a MIX of text and letters then you need to force them all to text values in the original data by highlighting the IDs column and choosing Format>Number>Plain Text from the menu bar.
UPDATE:
I understand the requirements better now for intermixing a cumulative month total into the output. This may work.
=ARRAYFORMULA({QUERY({EOMONTH('TAB1'!A2:A,0),'TAB1'!B2:C},"select 'Total',Col1,SUM(Col2) where Col3 = 1 group by 'Total',Col1 label 'Total''',SUM(Col2)''",0);QUERY('TAB1'!A2:C,"select '',A,SUM(B) where C = 1 group by '',A label '''',SUM(B)''",0)},"order by Col2,Col1",0))
I just want to run a simple weekly traffic report with the Google Analytics Sheets add on. It does work fine, but I can't seem to figure out how to sort the weeks in chronological order with the jump from 2019 to 2020.
This is how it looks like
Order of the weeks
Does anybody know what Order I need to enter to have the order from week 38 - 53 and then continue with 1,2...?
Include the year as dimension and order by year and by week, like this:
year week
2019 38
2019 39
2019 40
...
2020 1
2020 2
2020 3
For multi year weekly analysis, it's better to just use the corresponding Mondays for any date for your grouping/summing/analysis than it is to use "Week Numbers"
Those mondays can be obtained by using this arrayformula, assuming your dates were in column A (A2:A)
=ARRAYFORMULA(IF(A2:A="",,FLOOR(A2:A+5,7)-5))
I am using Google Sheets and am trying to find the largest value for cells that contain a specific year.
Example:
A B
DATE Value
1 jan 1875 4000
1 jan 1880 800
5 feb 1875 3500
6 jun 1875 2500
I have read about the MAXIFS function but am unsure how to apply it in this situation.
MAXIFS(B2:B4;A2:A4;1875) only returns "0" when I want it to return "4000" in B2.
I have tried substituting the "1875" in the formula with "YEAR(1875)" but it doesn't work.
It might be an issue with the dates being before 1900 but I've tried using years after 1900 as well, still it won't work.
Anyone here who knows?
I suggest a query instead of MAXIFS:
=query(A:B,"select max(B) where A contains 1875")
can it be that Google Sheets is not calculating right?
=DAYS360(DATE(2016;12;31); date(2017;1;1))
is 1 and also this is 1 but is should be 2:
=DAYS360(DATE(2016;12;30); date(2017;1;1))
Whats wrong here?
I think it is because of the formula that is set to 360 days. It is said here that DAYS360 - Days between two dates on a 360-day year. So it means that you will only have a 30 days a month not including the date 31 in the months of (Jan, March, May, July, Aug, Oct and Dec).
For example, you use this =DAYS360(DATE(2016,10,25), date(2016,10,30)) so the expected output is 5 - which is correct
If you use =DAYS360(DATE(2016,10,25), date(2016,10,31)) the expected output is 6 - because you specify the date 31.
But, if you use =DAYS360(DATE(2016,10,25), date(2016,11,3)), the output is 8 not 9 - because it did not include the date 31.
I hope I explained it clearly.
I am writing a Google Calendar sidebar gadget to keep track of the total hours per event tag (as determined in details of the event i.e. "tags: work").
Users can change the current week, month, day they are viewing in the calendar and I want to be able to count up the hours pertaining to their current view.
I don't see anywhere in the gadget API (or any other Google Calendar API) that allows gadgets to access the currently displayed view. I have noticed that the URL has an anchor tag that looks like
g|week-2+23127+23137+23131
which corresponds to viewing Monday Feb. 23, 2015 - Sunday March 1, 2015 in week mode.
I have also noticed the following relationships:
23127 is the first day in the view
23137 is the last day in the view
23131 is the day selected in the month view (on the left of the calendar)
If there is a way to get the currently displayed view using the API, that would be ideal but I would settle for parsing the anchor tag. Unfortunately I cannot decipher how the numbers work.
Google API
The currently displayed date range can be accessed using the following call:
google.calendar.subscribeToDates(function(d) {
// do something
});
where d is a Google date range d.startTime and d.endTime being the beginning and end.
Numbers
The numbers in the URL do not correspond directly to epoch date and time. Rather, each year has 512 days associated with it and each month has 32 days. For example, February has 28 days regularly but every leap year it has 29. The calendar never has to adjust for this since it simply allots each month 32 days and comes out with a nice even number every time.
A careful examination of the date ranges displayed will also show you that if you subtract the number for December 31 from January 1 you get 130. Accounting for the beginning and the end (don't count December 31 and January 1) will give you 128.
12 * 32 + 128 = 512 -- 12 months a year, 32 days a month and a 128 gap per year
Also, for some reason January 1, 1970 has the associated number of 33 so add that to your calculations when determining dates.
This wouldn't fit in the comments, but here's how the encoding works:
The encoding scheme makes it easy to find the day/month/year from the number.
Take 23131 which yields Feb 27, 2015 (from the example in your question).
Divide by 512 and add 1970 (epoch) for the year.
23131 / 512 = 45.xxx => 45 + 1970 = 2015.
Get the remainder of that division and divide by 32 to find the month.
23131 mod 512 = 91 / 32 = 2.xxx = February
Get the remainder of that division and it's the day.
91 mod 32 = 27