Populate Dates and Data With Criteria

kumara_faith

Well-known Member
Joined
Aug 19, 2006
Messages
955
Office Version
  1. 365
Hi,

I have the following table:

Day Expense.xlsx
ABCDEFGHIJKLMNO
1MonFoodLunch8Start Date10/7/202410/7/2024MonFoodLunch8
2MonFoodDinner8Holiday10/9/202410/7/2024MonFoodDinner8
3MonAltarFlower1510/10/202410/7/2024MonAltarFlower15
4MonFoodBread3.510/7/2024MonFoodBread3.5
5TueFoodLunch810/8/2024TueFoodLunch8
6TueFoodDinner810/8/2024TueFoodDinner8
7TueAutomobileToll1.7210/8/2024TueAutomobileToll1.72
8TueAutomobileToll10.7510/8/2024TueAutomobileToll10.75
9WedFoodLunch810/11/2024FriAutomobileToll1.72
10WedFoodDinner810/11/2024FriAutomobileToll10.75
11WedAutomobileToll1.7210/11/2024FriFoodLunch8
12WedAutomobileToll10.7510/12/2024SatAutomobileFuel60
13ThuFoodLunch810/14/2024SunFoodDrink10
14ThuFoodDinner8
15ThuAutomobileToll1.72
16ThuAutomobileToll10.75
17FriAutomobileToll1.72
18FriAutomobileToll10.75
19FriFoodLunch8
20SatAutomobileFuel60
21SunFoodDrink10
Sheet1


1) Column A to D shows the fixed expenses that will be incurred every week.
2) Cell H1 shows the start date for the week. This may or may not be a Monday
3) Cell H2 to H6 will show the holidays in the week.

I am trying to populate the expenses for the day based on the start date and exclude the holidays. The correct results are in column J to N. Is there a way to use a formula for this ?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
2) Cell H1 shows the start date for the week. This may or may not be a Monday
How should it treat the nature of a "week"? Your criteria above is ambiguous because a week is 7 days regardless of when it starts.
So for example, if your start date in example above was tomorrow (8-Oct-2024) so that the week starts on Tuesday, should the results include Monday anyway because it is then the 7th day of the "week". Or are you implying that the week starts on Monday and the length of the week is reduced depending on the start date (i.e. the week always ends on Sunday so a week commencing on Tuesday only has 6 days)?
 
Upvote 0
Hi,

Week here will be Mon to Sunday. If the start day is Tuesday, then the data will be for Tue to Sun. Hope this clarifies. Do let me know if you need further clarification.
 
Upvote 0
Is this OK? Note my dates are dd/mm/yyyy, and the holiday zone goes to row 8 for reasons required by the formula.

Book1
ABCDEFGHIJKLM
1MonFoodLunch8Start Date8/10/2024TueFoodLunch8
2MonFoodDinner8Holiday9/10/2024TueFoodDinner8
3MonAltarFlower1510/10/2024TueAutomobileToll1.72
4MonFoodBread3.5TueAutomobileToll10.75
5TueFoodLunch8ThuFoodLunch8
6TueFoodDinner8ThuFoodDinner8
7TueAutomobileToll1.72ThuAutomobileToll1.72
8TueAutomobileToll10.75ThuAutomobileToll10.75
9WedFoodLunch8FriAutomobileToll1.72
10WedFoodDinner8FriAutomobileToll10.75
11WedAutomobileToll1.72FriFoodLunch8
12WedAutomobileToll10.75SatAutomobileFuel60
13ThuFoodLunch8SunFoodDrink10
14ThuFoodDinner8
15ThuAutomobileToll1.72
16ThuAutomobileToll10.75
17FriAutomobileToll1.72
18FriAutomobileToll10.75
19FriFoodLunch8
20SatAutomobileFuel60
21SunFoodDrink10
Sheet1
Cell Formulas
RangeFormula
J1:M13J1=LET(_a,CHOOSE(WEEKDAY($H$1,2),7,6,5,4,3,2,1), _b,TEXT(SEQUENCE(_a,1,$H$1),"ddd"), FILTER($A$1:$D$21,ISNUMBER(XMATCH($A$1:$A$21,FILTER(_b,_b<>DROP(TEXT(IF($H$2:$H$8="",$H$2,$H$2:$H$8),"ddd"),7-_a)),0))))
Dynamic array formulas.
 
Upvote 0
Hi,

When I use the formula, I am getting as below:

Day Expense.xlsx
ABCDEFGHIJKLM
1MonFoodLunch8Start Date8/10/2024SatAutomobileFuel60
2MonFoodDinner8Holiday9/10/2024SunFoodDrink10
3MonAltarFlower1510/10/2024
4MonFoodBread3.5
5TueFoodLunch8
6TueFoodDinner8
7TueAutomobileToll1.72
8TueAutomobileToll10.75
9WedFoodLunch8
10WedFoodDinner8
11WedAutomobileToll1.72
12WedAutomobileToll10.75
13ThuFoodLunch8
14ThuFoodDinner8
15ThuAutomobileToll1.72
16ThuAutomobileToll10.75
17FriAutomobileToll1.72
18FriAutomobileToll10.75
19FriFoodLunch8
20SatAutomobileFuel60
21SunFoodDrink10
Sheet2
Cell Formulas
RangeFormula
J1:M2J1=LET(_a,CHOOSE(WEEKDAY($H$1,2),7,6,5,4,3,2,1), _b,TEXT(SEQUENCE(_a,1,$H$1),"ddd"), FILTER($A$1:$D$21,ISNUMBER(XMATCH($A$1:$A$21,FILTER(_b,_b<>DROP(TEXT(IF($H$2:$H$8="",$H$2,$H$2:$H$8),"ddd"),7-_a)),0))))
Dynamic array formulas.
 
Upvote 0
Hi,

Adjusted the date format and have the following.
Day Expense.xlsx
ABCDEFGHIJKLM
1MonFoodLunch8Start Date10/7/2024MonFoodLunch8
2MonFoodDinner8Holiday10/9/2024MonFoodDinner8
3MonAltarFlower1510/10/2024MonAltarFlower15
4MonFoodBread3.5MonFoodBread3.5
5TueFoodLunch8TueFoodLunch8
6TueFoodDinner8TueFoodDinner8
7TueAutomobileToll1.72TueAutomobileToll1.72
8TueAutomobileToll10.75TueAutomobileToll10.75
9WedFoodLunch8ThuFoodLunch8
10WedFoodDinner8ThuFoodDinner8
11WedAutomobileToll1.72ThuAutomobileToll1.72
12WedAutomobileToll10.75ThuAutomobileToll10.75
13ThuFoodLunch8FriAutomobileToll1.72
14ThuFoodDinner8FriAutomobileToll10.75
15ThuAutomobileToll1.72FriFoodLunch8
16ThuAutomobileToll10.75SatAutomobileFuel60
17FriAutomobileToll1.72SunFoodDrink10
18FriAutomobileToll10.75
19FriFoodLunch8
20SatAutomobileFuel60
21SunFoodDrink10
Sheet2
Cell Formulas
RangeFormula
J1:M17J1=LET(_a,CHOOSE(WEEKDAY($H$1,2),7,6,5,4,3,2,1), _b,TEXT(SEQUENCE(_a,1,$H$1),"ddd"), FILTER($A$1:$D$21,ISNUMBER(XMATCH($A$1:$A$21,FILTER(_b,_b<>DROP(TEXT(IF($H$2:$H$8="",$H$2,$H$2:$H$8),"ddd"),7-_a)),0))))
Dynamic array formulas.


Note that holidays are 9 and 10 Oct but the table results still show Thursday (10 Oct) . In addition, is there a way to also populate the date in column J as per the priginal post ? Appreciate it.
 
Upvote 0
Give this a try:
Excel Formula:
=FILTER($A$1:$D$21,
        ISNUMBER(
            XMATCH($A$1:$A$21,
                   TEXT(
                        WORKDAY.INTL($H$1-1,
                                     SEQUENCE(NETWORKDAYS.INTL($H$1,$H$1+7-WEEKDAY($H$1,2),"0000000",$H$2:$H$6)),
                                     "0000000",
                                     $H$2:$H$6),
                        "ddd"),
                    0)))
 
Upvote 0
Solution
Hi Alex,

That worked. Thank you for your solution and appreciate it. 🙏

Hi myall,

Thank you for your solution and patience as well.
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top