Time series mock data generation for 16 years of quarterly data in Excel or Matlab - excel

I would like to generate a mock time series quarterly dataset from, say, 2000-2016 for a variable (quarterly credit growth) that averages around a certain value (say, 30%). Can anyone give a suggestion on how to do this in principle?
Edit: what I was implying were the actual data values for each time period, i.e. data with a certain mean and variance.
Found a solution with a code in Matlab, for anyone interested, see below in answers.

Excel approach:
You can make column A your date list. In A1, or A2 or more if you have header rows, you will have to seed your list by providing the first start date. Lets assume you put your seed date in A2. I would then go about adding 3 month to you start date using a formula, and copy down until you have hit your desired date. In order to add the 3 months I would use the following in A3.
=date(year(A2),Month(A2)+3,day(A1)
that will give you the first day of the month every 3 months. If you want the first day of the month every 3 months, set the day to 1 like so:
=date(year(A2),Month(A2)+3,day(A1)
And end of month could be calculated as:
=eomonth(date(year(A2),Month(A2)+3,day(A1)),0)
however I would prefer to do the end of month calculation based on the row you are in so I would do it more like:
=EOMONTH($A$2,(rows($A$2:A3)-1)*3)

Related

Is a date within several date ranges

I'm trying to put together an excel spreadsheet to show the day-by-day impact of stays by 3rd country citizens in the EU's Schengen area (it's a fairly complex rolling 180 day window). At the moment, I have a column with every day from a start date (so lots of rows) and another where I enter a 1 if there was a stay in a Schengen country for that day. Then other columns calculate when the 180 day period started and how many days have been in Schengen for that day.
It's a bit of a faff having to enter a 1 for every day away. I'd like to have another worksheet where I simply enter the start and end dates of (an arbitrary number of) each stay and then the calculation spreadsheet simply works out if each date falls within a stay or not. Working out whether a date falls within one date range is pretty straightforward, but working out if it falls within several date ranges isn't obvious to me. Any suggestions please?
After a very fair comment, here's a couple of images that hopefully illustrate what I'm trying to do (please ignore the colours).
Example of date ranges, but the number of these should be arbitrary:
The calculated sheet - currently I have to enter the 1s individually whereas I'd like them evaluated from the date ranges:

Excel - Photovoltaic - converting hours

I have a problem that I would like to solve. I got data in excel, which are
in this form, basically I have number of hours from 0 to 8760 in a column in excel, which represent the whole year. And in another column I have "Power from PV" which corresponds to how much power does photovoltaic system produce in that specific hour. I would like to convert these hours to months, so I could make a graph of monthly production of power in a whole year. Is there some sensible way to do this in excel?
Thank you for any suggestions.
You need three things:
You need to know that 1 equals 1 day, so if you want to convert hours into date related information, you need to divide it by 24.
There is a function, called Date(), which gives the date, based on year, month and day, like =DATE(2022,1,1).
There is a function, called Month(), which gives the month number of a date.
So, in summary, you need something like:
=MONTH(DATE(2022,1,1) + A3 / 24)
Once you have this in a new helper column, you can start using the Subtotals basic Excel feature.

Get sum of cells containing "Vacation" except when related date matches certain day & month

oversimplified i have two columns: Date and Text; I want to check my current amount of vacation days based on the first date in row 2, so i came up with the following formula:
="Available vacation days: "&YEARFRAC(A2;TODAY())*12*(25/12)
I calculate the fraction of the year based on the first date and todays date, multiply it by 12 to get months and multiply it again by the total amount of vacation days in my contract per month. Now i got another formula to collect me all cells in column B containing "Vacation", pretty straight forward:
=COUNTIF(B:B;"Vacation")
Now the interesting part - i got the formula who gives me a boolean if a datetime matches the 24th or 31st of december:
=AND(OR(DAY(A53)=24;DAY(A53)=31);MONTH(A53)=12)
I want to count vacation days happening on a 24th or 31st of december as a half-vacation day (0.5), and otherwise fully (as a 1). Then i want to combine my first statement with this result and subtract the used vacation days. I read about VLOOKUP and XLOOKUP but am unsure if this fits this purpose. I want to avoid having an extra column with my boolean returns and rather have this one cell giving me all the information combined.
Without introducing another column, and using DAY and MONTH
It's nearly impossible, and just unnecessarily so...
Please reconsider this, what will happen if you want to add 4th of July as a holiday?
Your formula =AND(OR(DAY(A53)=24;DAY(A53)=31);MONTH(A53)=12) only works for 1 row at a time. So, we can't ever use it with a list, because you will get the whole list as a result every single time. You can't divide them into smaller lists and join them together, there is no such functionality without VBA.
In the future, do not set arbitrary constraints like "no additional columns", you can hide them if you don't like them. And if you don't need them, remove unnecessary rows like non-vacation rows. They are irrelevant, so why not separate the two.
Just to prove my point, here's the solution you wanted:
Solution
=COUNTIFS(B2:B9;"Vacation") - (COUNT(IFERROR(FILTER(FILTER(FILTER(A2:A9;B2:B9="Vacation");MONTH(FILTER(A2:A9;B2:B9="Vacation"))=12);DAY(FILTER(FILTER(A2:A9;B2:B9="Vacation");MONTH(FILTER(A2:A9;B2:B9="Vacation"))=12))=31);0))+(COUNT(IFERROR(FILTER(FILTER(FILTER(A2:A9;B2:B9="Vacation");MONTH(FILTER(A2:A9;B2:B9="Vacation"))=12);DAY(FILTER(FILTER(A2:A9;B2:B9="Vacation");MONTH(FILTER(A2:A9;B2:B9="Vacation"))=12))=24);0))))*0,5
It works, but it's a pain to read, use and maintain.
A2:A9 refers to the dates column
B2:B9 refers to the text column
So in the future, the last thing you want to do is set arbitrary constraints. Furthermore, why use functions like MONTH and DAY when we can just read the text? That way you could even create a table of holidays to search for instead. That will be no fun task with this setup. (Oh, and if it's because of the year, just strip it away from the text when you want to know only the month and day.
Best of luck!

How to forecast values based on 3/5/7/10 etc. last observations (Excel)?

I have two columns of observations: Date and Number of Registrations.
Date
Registrations
01-05-2020
7841772
02-05-2020
8101873
03-05-2020
8065389
04-05-2020
7127299
...
...
19-05-2020
7208950
20-05-2020
7117984
21-05-2020
7906914
22-05-2020
to forecast
23-05-2020
to forecast
24-05-2020
to forecast
...
...
My task is to forecast the number of registrations for the remaining days based on 3/5/7/10 last values. So the first time I have to pick values from May 19th till May 21st, the second time - from May 17th till May 21st and so on.
The problem is, that there is a cell with a fixed number of days I have to use. There is a dropdown list that should affect the forecast every time I change the value in it.
I've been struggling the whole day to adjust my forecast.linear() function so it takes into account these changes.
Would appreciate any help.
If I have understood the question, you could use an OFFSET. It is a volatile function, so you would not want to use this if you have to implement it on many sheets and if there is a lot of data entry as it will make the worksheet slow.
If you put the dropdown in D1, and your dates are in A and values in B, then the formula in the forecast area would be:
=FORECAST.LINEAR(A23,OFFSET($B$22,0,0,-$D$1,1),OFFSET($A$22,0,0,-$D$1,1))
Where row 22 is the 21st of May as shown in your table above.

Number of times an event occurs per year depending on start date and frequency (excel)

I'm trying to develop a formula in MS Excel that will give me the number of occurrences a task will happen in a year (or month), based on a start date, frequency and schedule in a table. I am looking to produce a table like the following (assuming the start date is 01/01/YR1):
I'm open to VBA suggestions also.
The minimum frequency is completing the task every week. Not taking into account daily tasks here. The data is held in a table. I calculated the 'times per year' using :
=IF([#Schedule]="Months",(12/[#Frequency]), IF([#Schedule]="Weeks",(52/[#Frequency]),IF([#Schedule]="Years",1/[#Frequency],0)))
I may look to take this onto a monthly schedule also, i.e. number of occurrences for each month across 5 years. It would also be useful to specify an overall end date for when the tasks would stop. (e.g. sometimes it would be year 3, sometimes year 5)
Your help is much appreciated!
=IF(D$2=1,ROUND(D$2*$C3-0.45,0),ROUND(D$2*$C3-0.45,0)-SUM($D3:OFFSET($C3,0,D$2-1)))
The formula is dragable so just place it in D3 then drag across then down. Also note the change in format of the table so the year numbers are usable in the calculations.
Note: I would suggest that the value the 5th year of the 2.5 year frequency is incorrect.
In the 3rd year you would do it and have a half year remaining. Then add that to years 4 & 5 and you get 2.5 time to do it again.

Resources