Percentage formula that skips over blank weekends - excel

In an excel spreadsheet I have data that looks like:
Basically column A has the dates from the beginning of the year to the end of the year then Column B I manually enter values every Monday-Friday, Column C to get -2.3% I used the formula "=(C2727-C2726)/C2726" where 2727 and 2726 have the values 134,655 and 137,849 respectively. Then lastly column D has the days of the week.
The problem I have is that my current formula I have to enter every day because Monday and Tuesday get messed up because Saturday and Sunday are always blanks. So what I would like is a dynamic formula that does the same thing but for Monday it does "(Monday-Friday)/Monday" and Tuesday it does "=(Tuesday-Monday)/Monday"
Any help is appreciated

You could do in Column C:
= CHOOSE( MIN( 3, MOD( WEEKDAY( A5 ) - 1, 6 ) + 1),
"",
( B2-B5 ) / B2,
( B5-B4 ) / B5
)
and copy it down, where Column B contains your values and Column A contains your dates.
Note, however, that you will need to handle the first cell that ends up referencing your titles or start of data. Look at cell B4 in the above example: it errors out because it tries to calculate with B1 which contains a title. You may want to wrap this in an IFERROR:
= IFERROR( CHOOSE( MIN( 3, MOD( WEEKDAY( A4 ) - 1, 6 ) + 1),
"",
( B1-B4 ) / B1,
( B4-B3 ) / B4
),
"n/a" )

Related

Get dollar value from adjacent cell where day of month is in a date range

I have an excel workbook with two worksheets.
One holds static values that lists bill due each month, with a day of month column as an integer (or it can be, right now its attached to a string), a bill name column as a string and a dollar amount. I would like to pull the bill name and the amount if the day of month falls within a date range on the other sheet.
The other sheet lists out a date range of a week for the whole month, and includes the name of the bill, and the amount due during that week. I would like to automatically populate those columns using values from my static sheet, where the day of month in the static sheet falls between the date range in the month sheet. I have attached screen shots of what I am aiming for. This is simply sample data. I would like the month sheet columns(Both bill name and amount) to be auto populated when I enter dates in the header columns from the static sheet.
Assume the static values sheet is named "Static", and the month sheet is named "December".
I would be happy to provide more information/images/sample files as needed. This is a hobby of mine, and questions, discussion, criticism is encouraged.
Update
With the formula posted by mark, this works flawlessly when the date ranges are within the same month.
=LET( st, H1, fn, I1,
expenses, $D$3:$F$10,
na, INDEX( expenses, SEQUENCE( ROWS( expenses ) ), {1,2}), d, INDEX( expenses,, 3),
FILTER(na, (d>=DAY(st))*(d<=DAY(fn)) ) )
However, when the date ranges include a month change for example: December 30 through January 5th, Excel shows an error "Empty arrays are not supported".
With Office 365, you can do:
=LET( st, H1, fn, I1,
expenses, $D$3:$F$10,
na, INDEX( expenses, SEQUENCE( ROWS( expenses ) ), {1,2}), d, INDEX( expenses,, 3),
FILTER(na, (d>=DAY(st))*(d<=DAY(fn)) ) )
where H1 is your starting date of the period, I1 is the finishing date and D3:F10 is the array of Name, Amount and Day of month as you have shown.
This formula will spill the results with Name and Amount. It can be copied to other cells as you have shown in your Sheet2 example (i.e., A3, D3, G3... in Sheet2).
If you don't have Office 365, it will be harder.
Version II - Account for month cross over
This will accommodate the crossover of the month. Did not think about that...
=LET( st, H1, fn, I1,
expenses, $D$3:$F$10,
s, DAY( st ), f, DAY( fn ),
na, INDEX( expenses, SEQUENCE( ROWS( expenses ) ), {1,2}), d, INDEX( expenses,, 3),
b, IF( MONTH(st) = MONTH(fn), (d>=DAY(st))*(d<=DAY(fn)), (d>=DAY(st))*(d<=DAY(EOMONTH(st,0))) + (d>=1)*(d<=DAY(fn)) ),
FILTER(na, b ) )

Excel formula to derive next available date basis uneven frequency

Below is a table where Column A has given date, and Column C through I are days on which future dates can occur. 0 stand for cannot occur, 1 stand for can occur.
Basis the occurrence, I am trying to figure out a formula which can tell me what is the next available date.
For Ex: In case of Monday 8th Jun, Mon is 0, hence next available date is Tue 8th Jun
For Ex: In case of Sunday 13th Jun, Mon & Sun are 0, hence next available date is Tue 15th Jun.
While (if) formula can handle this, but the frequency nature is dynamic hence need a smarter approach.
Preferably a formula based approach.
Use the following array formula in B2:
=A2+IFERROR(SMALL(IF(($C$2:$I$2=1)*(COLUMN($C$2:$I$2)>=WEEKDAY(A2,2)+2),COLUMN($C$2:$I$2)),1)-WEEKDAY(A2,2)-2,SMALL(IF($C$2:$I$2=1,COLUMN($C$2:$I$2)),1)-WEEKDAY(A2,2)-2+7)
Array-formula is entered with ctrl+shift+enter
WEEKDAY(A2,2) returns the number of the day in the week: 1 for Monday, 2 for Tuesday, etc. SMALL(IF(($C$2:$I$2=1)*(COLUMN($C$2:$I$2)>=WEEKDAY(A2,2)+2),COLUMN($C$2:$I$2)),1)-WEEKDAY(A2,2)-2 This part makes an array of the current row and returns the smallest column number that meet the following conditions: 1) cell in the range (row) has value 1. 2) the column number of the cells resulting from condition 1 is equal to or greater than the calculated WEEKDAY +2 (weekday for Monday = 1+2 =3) so if column 3 contains value 1 it's a hit, else it will look for the first next column that does meet the conditions. As the desired result should return the date of the result we add the column of the result of this evaluation to the original date and extract the WEEKDAY -2 (minus, because we need to extract *more). The IFERROR is built to search in the next row if there is no value 1 in the column equal to or greater than weekday +2. In that case it would return the first column of the next row containing value 1.
If you have Excel 2019 or Excel 365, in B, you could put the formula:
=LET( gDate, A2,
pattern, C2:I2,
s, SEQUENCE( 7, 7, 0 ),
k, MOD( s, 8 ) - ( INT(s/7) > MOD(s,7) ),
gDate + MIN( IF( pattern > 0, INDEX( k, WEEKDAY( gDate,3 )+1, ) ) ) )
I keep thinking that there has to be a simpler way than this, but none of my simpler approaches generate the results you are trying to achieve.

Return value based on earliest date value within set

I'm looking for a formula to return the value from Column E, based on the earliest date in column B, within the Values in Column A in Sample table I attached.
I this instance, I seek to return 50% for Company A, 75% for Company B, and 50% for Company C.
Sample Table
Thanks in advance
Assuming sample data is located at A1:E7 (adjust formulas as required)
(Enter the FormulaArray pressing [Ctrl] + [Shift] + [Enter] simultaneously, you shall see { } around the formula if entered correctly)
To list Companies enter this FormulaArray in G2` and copy till last record
=IFERROR( INDEX( $A$1:$A$7, MATCH( 0, COUNTIF( $G$1:$G1, $A$1:$A$7 ), 0 ) * 1 ), "" )
To extract the earliest % Passed for each company enter this FormulaArray in H2 and copy till last record
=IF( EXACT( $G2, "" ), "",
INDEX( $E$1:$E$7,
MATCH( SMALL( IFERROR( $B$1:$B$7 * ( $A$1:$A$7 = $G2 ) * 1, 0 ),
1 + COUNTIF( $A$1:$A$7, "<>" & $G2 ) ),
$B$1:$B$7 * ( $A$1:$A$7 = $G2 ) * 1, 0 ) ) )
To get the percentage for when column A has a value of "A":
=MAX((MIN(IF(B2:B99*(A2:A99="a"),B2:B99))=B2:B99)*E2:E99)
This is an array formula and must be confirmed with Ctrl+Shift+Enter.
Note: if your data extend further down than row 99, then increase the 99s in the formula.
Note: you can edit the "a" in the center of the formula for "b" or "c". Better still would be a reference to a cell containing the value to calculate on. For example, let's say you enter A in cell G1, you could do this:
=MAX((MIN(IF(B2:B99*(A2:A99=G1),B2:B99))=B2:B99)*E2:E99)

Distribute Cell Value Over Column of Cells

I want to distribute a value over a column of cells in multiples of 0.25. For instance, if my value is 6 and my column consists of 10 cells, I want 6 of the cells to have a value of 0.5 and 4 of the cells to have a value of 0.75 to sum to 6.
Another example would be if the value was 1 and I wanted to distribute that over the same column of 10 cells. 4 of the cells should have a value of 0.25 and 6 should have a value of 0.
The unequal cells could either be the first 4 in the column or randomly selected from the 10.
This solution requires the following:
Range to enter variables located at B3:C6 (see fig. 1)
Number: Number to be distributed. Enter 6 in C3
Divider: Enter 0.25 in C4
Parts: Number of parts to distribute. Enter 10 in C5
Multiples: Formula to calculate & validate the parts to be allocated. Enter this formula in C6
=IF( MOD( $C$3 , $C$4 ) <> 0 , "!Err" , $C$3 / $C$4 )
Range to calculate the distribution located at E2:G13 (see fig. 1)
Parts: Keeps the relationship between distribution and part number. Enter this formula in E3 then copy till last record
=SUM( 1 , E2 )
Times: Number of times each part number contains the multiple. Enter this formula in F3 then copy till last record
=SUM( INT( $C$6 / $C$5 ) , IF( $E3 <= MOD( $C$6 , $C$5 ) , 1 , 0 ) )
Distribution: Resulting distribution. Enter this formula in G3 then copy till last record
= $C$4 * $F3
Total: validation of the distribution. Enter this formula in E3 then copy till last record
=IF( ROUND( SUM( $G$3:$G$12 , -$C$3 ) , 2 ) <> 0 , "!Err" , $C$3 )
Fig. 1
Fig. 2

How Can I Change Repeating date to one in excel?

I have below question:
On column A1: A16, I have some repeated dates.
On column B1:B16, I have the numbers which are assigned each one only to a date on column A. For instance, B1 to A1, B2 to A2 and etc.
I copy column A to column C and use from Data – Remove Duplicates.
Now, I want to have total sum of numbers which are assigned to each exact date on column D (front of column C).
I have attached an example of excel sheet.
How can I do?
4/4/2015 20000000 4/4/2015 94010000
4/4/2015 9510000 4/9/2015
4/4/2015 50000000 4/13/2015
4/4/2015 14500000 4/14/2015
4/9/2015 200000000 4/19/2015
4/9/2015 200000000 4/27/2015
4/13/2015 672716000
4/14/2015 28448000
4/19/2015 26168000
4/19/2015 26168000
4/19/2015 18568000
4/19/2015 18568000
4/27/2015 41368000
4/27/2015 13500000
4/27/2015 200000000
4/27/2015 52926000
Extract Unique Items and Corresponding Totals
Assuming that your data is located as follows:
Dates range B7:B21 and Amounts range C7:C21
To extract a list of unique dates enter this FormulaArray in E7 and copy till last record:
(Formulas Array are entered by pressing [Ctrl] + [Shift] + [Enter] simultaneously)
=IFERROR( INDEX( $B$7:$B$21, MATCH( 0, COUNTIF( $E$6:$E6, $B$7:$B$21 ), 0 ) * 1 ), "" )
Then to have the total amount for each date in the next column enter this formula in F7 and copy till last record:
=IF( EXACT( $E7, "" ), "", SUMIF( $B$7:$B$21, $E7, $C$7:$C$21 ))

Resources