How to allocate varying length historical Excel data into percentages of elapsed time? - excel

For example, if I have the following simple data:
ID
January
February
March
April
May
June
1
5
8
4
2
2
10
3
3
6
2
7
1
4
3
I am trying to formulate a way to essentially allocate the amounts in each row into an equal number of columns by converting months into percentage of time elapsed. So if I were to use periods of 25% of time elapsed, it would look something like this:
ID
P1 (25% of lifetime)
P2 (25% of LT)
P3 (25% of LT)
P4 (25% of LT)
1
5
8
4
2
2
10*.5
10*.5
3*.5
3*.5
3
6+(.5*2)
(.5*2)+7
1+(.5*4)
(.5*4)+3
Note that each row sums up to the same amount as the original, they are just now allocated based on percentages of time elapsed (thus same number of columns). Are there any formulas or methods so this wouldn't have to be done manually? Any help is appreciated.

Related

Excel: how to average with condition

We have an Excel sheet in which we collect some monthly data.
Each line contains a date and some value (in my boiled-down example here the date is always the first of each month and the values are [1..n]).
I am now trying to calculate an average of the values but not from ALL values but only those from the last quarter (i.e. where Date is >TODAY()-90).
TODAY() at the time of this writing is Jan. 30th, 2023, so I would expect the result to be 12, i.e. the average of the values for the last 3 months (11, 12, and 13).
A B
1 Date Value
2 01.01.2022 1
3 01.02.2022 2
4 01.03.2022 3
5 01.04.2022 4
6 01.05.2022 5
7 01.06.2022 6
8 01.07.2022 7
9 01.08.2022 8
10 01.09.2022 9
11 01.10.2022 10
12 01.11.2022 11
13 01.12.2022 12
14 01.01.2023 13
15
16 Avg. last 3 months:
17 #VALUE! <-- =AVERAGE(IF(A2:A14>(TODAY()-90);B2:B14;0))
18 #DIV/0! <-- =AVERAGEIF(A2:A14;">(TODAY()-90)";B2:B14)
I tried several approaches using AVERAGE(...) and AVERAGEIF(...) functions as shown above (and also several other variants) but I could not manage to get this working. All I ever get are error messages like #VALUE! or #DIV/0! :-(
Any idea how I can convince AVERAGE(IF) to only consider those values where the date is >today-90 days?
As per my comment:
=AVERAGEIF(A2:A14,">="&TODAY()-90,B2:B14)
Where the ampersand calculations operator is just a less-verbose way to concatenate different values. Here the 2nd parameter takes a string so using both parts on the left and right of the operator we create a value such as ">=12345".

Is there a way to dynamically subtracting paid amount from total amount and get a remaining amount in google sheet

This is what I tried.
For below table
A B C
1 Expenses Cost Status
2 Expense1 30000 PAID
3 Expense2 20000
4 Expense3 7500
5 Expense4 520
6 Expense5 2300
7 Expense6 1000
8 Expense7 11618
9 Expense8 7939
10 Expense9 6473
11 Total 87350
12 **Remaining Amount ??**
if a column C cell has "PAID", then Substract Total amount(B11) from the PAID(B2) amount.
=IF(C2:C10="PAID",MINUS(B11,B2:B10),B11)
But this code only subtracts the first PAID amount, do not consider for other cells with PAID
Hoping for help!
You can use the formula SUMIF in it.
Considering that the Total is on column B11 and the Remaining would be on column B12, you can use the formula on B12:
=B11-(SUMIF(C2:C10, "PAID", B2:B10))
The number on the remaining will be going down after each expense gets paid.

Manipulating function sample sizes in Excel

Suppose I had two time series consisting of weekly data points, and I want to compute the covariance of the time series for the last n weeks using the covariance function in Excel.
Would it be possible to set this scenario up in such a way that a certain cell contains the number of weeks of data I want to compute the covariance for?
That is, changing the cell element to k would lead to the already computed covariance for n weeks to change to the covariance of the data series for the last k weeks?
You decided that sample data was not important so here is some.
date nmbr
03-30-2017 4
04-04-2017 4
04-07-2017 2
04-09-2017 2
04-12-2017 1
04-15-2017 4
04-18-2017 1
04-21-2017 2
04-24-2017 1
04-26-2017 3
04-30-2017 4
05-02-2017 5
05-07-2017 4
05-09-2017 2
05-10-2017 1
05-12-2017 5
05-14-2017 4
My crystal ball tells me that this question is not so much about Excel's COVARIANCE.P or COVARIANCE.S but about limiting date related data. To this end, I'll simply SUM 4 weeks of data.
The formulas needed in E2:H2 (see supplied image) are:
=TODAY()
4
=FLOOR(E2-(F2*7), 7)+1
=SUM(INDEX(B:B, MATCH(G2, A:A)+ISNA(MATCH(G2, A:A, 0))):INDEX(B:B, MATCH(1E+99, A:A)))
Note that the dates are in ascending order.

Sort by horodate on Excel

I would like to sort my Excel file by horodate so when we switch from summer time to winter time data is ordered by chronological order and so that when I create a graph the data is represented in the right order.
When i sort by horodate (from a to Z) i obtain that:
Horodate Value Chronological order
2014-10-26T01:30:00+02:00 32273345000 1
2014-10-26T02:00:00+01:00 28310393000 4
2014-10-26T02:00:00+02:00 31705207000 2
2014-10-26T02:30:00+01:00 27116547000 5
2014-10-26T02:30:00+02:00 29900587000 3
2014-10-26T03:00:00+01:00 26535312000 6
2014-10-26T03:30:00+01:00 26165805000 7
2014-10-26T04:00:00+01:00 26022551000 8
Which is not the chronological order as you see.. I would like to have 1 2 3 4 5 6 7 8
Thank you
You can add helper column and sort using it:
Formula in D1 (dragged down) is:
=SUBSTITUTE(LEFT(A1,19),"T"," ")-RIGHT(A1,5)*(MID(A1,20,1)&"1")
First part (SUBSTITUTE(LEFT(A1,19),"T"," ")) calculates date and time part, second (-RIGHT(A1,5)) timezone offset, and the third (MID(A1,20,1)&"1") sign of timezone offset (you can remove it, if there is always + in horodate).

Addition for two dimensional Excel

I needed some help with conditional addition in Excel.
This is an example data:
A B C D
1 Animal January February March
2 Cat 5 6 7
3 Cat 2 3 5
4 Dog 1 4 8
How can I write SUMIF on the conditions on, add total cats for the month of March?
I have been trying to experiment with SUMIF and written something like:
=SUMIF(A:A,Cat,D:D)
This is only going to work on one dimensional, meaning colum. How do I write a formula to calculate the sum of total cats in March? Column+ March , two dimensional.
You may try this:
=SUMIF(A1:A4;"Cat";INDEX(B1:D4; 0; 3))
The value of 3 in INDEX function means the third column (March), you may change it into 2 for February, and change it into 1 for January

Resources