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

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 ) )

Related

Percentage formula that skips over blank weekends

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" )

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.

Excel: Lookup Multiple values with duplicates in multiple columns

I'm trying to link multiple lists and show all the values. Including duplicates.
My worksheet has data in 11 Columns. One column with Products(which can appear multiple times) and the rest with Store(which sell the products, no store sells the same product).
A small example here:
I've made a helper column(A) using the following formula : =B2&COUNTIF($B$2:B2,B2) . The helper column counts how many time a product show up in the Products Column(B). I thought it was needed.
I've managed to sort the data a bit using =VLOOKUP($C$2&ROWS($L$1:L1),$A$2:$C$11,2,0) like this :
Result
But I want to sort the data in a single Column for each store like this:
Desired Result
, without having to change the formula every 2-3 rows, as some store have 30 or so products. Is this something achievable with either formulas or VBA?
I would like to have the results in one column :
List Store 1 items as many times as they appear in Product column.
If an item(from Store 1) doesn't show up in Product column show "Product name -"
Product Column can have repeatable items
Each store has different products, so there's no conflict there.
If possible, since i have they Helper Column, if a product shows up 4 times, when i drag the formula in the 5th row it should jump to the next product.
Hope this is clear enough. Thank you
Later Edit: Maybe this helps a bit in understanding what I want to obtain.
Column 1 helper I've added it to count how many times a product shows up in Column 2. I want to get a separate column, which shows the items in Column 3(store1) x how many times they appear in Products Column. In the example above Store1 has product "Hansa" which appears 4 times in Product Column so it should appear 4 times in the separate column, after it there's product "Korek" which appears 1 time in Product Column so it should appear one time in the separate column under "Hansa" and so on. So basically I want to compare the third column to the second and show to values in the third x times they appear in the second in a different column.
This formula uses F1 as a helper cell, which is needed to count the matches in the product list.
Enter this FormulaArray in F1:
=SUM( IF( ISERROR( MATCH( $B$2:$B$11, $C$2:$C$6, 0 ) ), 0, 1 ) )
Enter this formula in E2:E11:
= IFERROR( INDEX( $C$2:$C$6,
AGGREGATE( 15, 6,
MATCH( $B$2:$B$11, $C$2:$C$6, 0 ),
ROWS( E$2:E2 ) ) ),
IFERROR( INDEX( $C$2:$C$6,
AGGREGATE( 15, 6,
ROW(E:E) / ISERROR( MATCH( $C$2:$C$6, $B$2:$B$11, 0 ) ),
ROWS( E$2:E2 ) - $F$1 ) ) & "-", "" ) )
Note that the helper column A is not needed.

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)

Combine two rows of strings in a specific order using formulae

I have a column in on sheet like this:
Barbie
HeMan
Superman
Batman
and another column in another sheet like this:
Madrid
Barcelona
Athens
London
Timbuktu
I need output as below (preferably two columns, alternatively space separated in one):
Barbie Madrid
Barbie Barcelona
Barbie Athens
Barbie London
Barbie Timbuktu
HeMan Madrid
HeMan Barcelona
HeMan Athens
HeMan London
HeMan Timbuktu
How can this be done using Excel formulae please?
This solution assumes the following:
Data with “Super Heroes” is located in Sheet1 at B6:B9 (adjust ranges in formulas as required)
Data with “Cities” is located in Sheet2 at B6:B10 (adjust ranges in formulas as required)
Data combined is located in Sheet3 starting at B6 (adjust ranges in formulas as required)
Enter this formula in Sheet3 at B6 and copy till last record (i.e. ~ B31)
=IFERROR( INDEX( Sheet1!$B$6:$B$9,
ROUNDUP( ROWS( B$6:B6 ) / ROWS( Sheet2!$B$6:$B$10 ), 0 ) ), "" )
and this formula in Sheet3 at C6 and copy till last record (i.e. ~ C31)
=IF( EXACT( B6, "" ), "", INDEX( Sheet2!$B$6:$B$10,
1 + MOD( -1 + ROWS( C$6:C6 ), ROWS( Sheet2!$B$6:$B$10 ) ) ) )
Assuming that the first and second of your lists are in column A of Sheet1 and Sheet2 respectively, and that there are no other entries in those columns apart from the data you wish to be returned, then, in cell A1 of your worksheet chosen to house the results:
=IF(ROWS($1:1)>COUNTA(Sheet2!A:A)*COUNTA(Sheet1!A:A),"",INDEX(Sheet1!A:A,CEILING(ROWS($1:1)/COUNTA(Sheet2!A:A),1)))
And in B1:
=IF(A1="","",INDEX(Sheet2!A:A,1+MOD(ROWS($1:1)-1,COUNTA(Sheet2!A:A))))
Copy both down until you start to get blanks for the results.
Regards

Resources