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.
Related
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!
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.
OK, I am very new at this and have been googling things for the past few hours and have not found anything. Maybe I'm not looking for the right thing or I'm not looking hard enough but I am here now.
I have 3 calculations I need to do for each month (over 5 years) to be displayed as columns (3*12*5=180 total columns). I have mock formulas in Excel:
Fraction of Month =IF(AND(FEStart>=s01Y15,FEStart<=e01Y15),IF(FEStart=s01Y15, 1, ((e01Y15-(FEStart))+1)/DAY(e01Y15)),IF(AND(FEEnd>=s01Y15,FEEnd<=e01Y15),IF(FEEnd=e01Y15, 1, ((FEEnd)-(s01Y15))/DAY(e01Y15)),IF(FEEnd<=e01Y15, 0, IF(FEStart<=s01Y15,1,0))))
Year of Person =IF(AND(FEStart>=s01Y15,FEStart<=e01Y15),1,IF(AND(FEEnd>=s01Y15,FEEnd<=e01Y15),INT((s01Y15-FEStart)/365)+1,IF(FEEnd<= e01Y15, 0, IF(FEStart<=s01Y15,INT((s01Y15-FEStart)/365)+1,0))))
Monthly Salary =([Fraction of Month]*(SF/12))*(1.03^([Year of Person]-1))
Where
FEStart is the Start Date of the Person (entered by user)
s01Y15 is the start of the first month in 2015 (parameter set by me)
FEEnd is the End Date of the Person (entered by user)
e01Y15 is the end of the first month in 2015 (parameter set by me)
SF is the Annual Salary of the person (entered by user)
I understand that IF() has to be changed to IIF() and to use AS to name the field in the query for the sql code. However, I’m trying to see if I can make some sort of loop so I don’t have to manual change the variables and have 180 line written out. If I have to do that, I will. But I would really rather not.
Is there some way to use a while loop or for loop or some other loop to have MS Access create these 180 columns for me, without having 180 lines of code? Or do I just have to copy and paste a ton?
DISCLAIMER: I am using MS Access 2013. Also, I have some experience with VBA code in Excel (and I’m far more comfortable using Excel than MS Access) but am unsure of how to add VBA code to a query (I have added it to my forms).
I also had the idea to change the values of s01Y15 and e01Y15 in each loop but that might be a bit more complicated too so I just have (12*2*5=120) 120 variables set to the start and end dates of every month (which is probably not the best idea in retrospect). Anyways I still cannot get a loop to work in a query (if it even is possible).
EDIT: Not sure if this is helpful, but this is what I have:
Input data for People Table:
Person’s name (separated into f/l), Start/End Date (FEStart/FEEnd), Salary (SF).
People Query to show: Person’s name, Start/End Date (FEStart/FEEnd), Salary (SF), & the 180 columns I described above.
Restrictions on Calculations: Fraction of a Month should be a positive number no larger than 1. Year of person starts as a 1 and increases (by one) after each year (essentially infinitely but I am only doing 5 years – so with a max of 5). Monthly salary can be infinite.
Here is an example for an entry in the People table:
FName | LName | FEStart | FEEnd |SF
Anakin | Skywalker | 7/1/2017 |6/30/2019 |120,000.00
This is a little oversimplified because really the start and end dates are pulled form another table, connected by the “people id”.
Please see the link for the calculations.
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)
I am attempting to get the total hours between two times in a SharePoint 2007 list. Right now I have the formula as...
=INT(([Column2]-[Column1])*24)
...which I have looked up and says that it is the correct formula to do this. But, what I get is a weird date like "2/18/1900 12:00 AM" instead of what it should be: 26.
Another formula I tried was...
=TEXT([Column2]-[Column1],"h")
...but, this will only get the difference in hours and not count the days (if they are more than one apart).
Both of the columns are Date & Time columns. So, what am I doing wrong?
My take is that you set the output format of the calculated column to be Date and Time, while it should be of type number.
In a calculated column, the number of hours between two times is:
=TEXT([Column2]-[Column1],"h")
Providing that the difference is less than 24 hours. Otherwise, you'll need to look at getting the days difference and doing a multi-step calculation involving the number of days between the dates * 24 + the calc above.