Array Query on Filter()

mart_mrexcel

Active Member
Joined
Aug 23, 2008
Messages
295
Office Version
  1. 365
Platform
  1. Windows
I have an auto-filter for Anniversary & Birthday in a Month(Today()). In the table,
a.) how can I filter the Hire date and/or birth date in column "G"
b.) In column H, I want to put "Anniversary" or "Birthday"
c.) in the given example, Jose has 2 events in January (i.e. Anniversary and Birthday), I want to make his name appear 2 times in the table with Anniversary and Birthday in Column H.

Thank you



Book1
ABCDEFGHI
1Employee IDHire DateBirth DateEmpDateHeader Name
2Stacy16-Jan-0701-Jun-68Stacy
3Derek10-Jul-1614-Jul-75Jose
4Martin21-Sep-1716-Aug-82Peter
5Jose18-Jan-1813-Jan-95
6Peter26-Nov-1713-Jan-94
7Lance25-Feb-1801-Feb-95
8Judith01-Apr-1815-Mar-82
9
10
11
12
13
Sheet1
Cell Formulas
RangeFormula
F2:F4F2=FILTER(EmpMstr[Employee ID],(MONTH(EmpMstr[Hire Date])=MONTH(TODAY()))+(MONTH(EmpMstr[Birth Date])=MONTH(TODAY())))
Dynamic array formulas.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
How about
Fluff.xlsm
ABCDEFGH
2Employee IDHire DateBirth DateEmpDateHeader Name
3Stacy16/01/200701/06/1968Stacy16/01/2007Hire Date
4Derek10/07/201614/07/1975Jose18/01/2018Hire Date
5Martin21/09/201716/08/1982Jose13/01/1995Birth Date
6Jose18/01/201813/01/1995Peter13/01/1994Birth Date
7Peter26/11/201713/01/1994
8Lance25/02/201801/02/1995
9Judith01/04/201815/03/1982
10
Lists
Cell Formulas
RangeFormula
F3:H6F3=LET(d,EmpMstr[[Hire Date]:[Birth Date]],m,MONTH(TODAY()),HSTACK(TOCOL(IF((MONTH(d)=m),EmpMstr[Employee ID],x),2),TOCOL(IF((MONTH(d)=m),d,x),2),TOCOL(IF((MONTH(d)=m),EmpMstr[[#Headers],[Hire Date]:[Birth Date]],x),2)))
Dynamic array formulas.
 
Upvote 0
How about
Fluff.xlsm
ABCDEFGH
2Employee IDHire DateBirth DateEmpDateHeader Name
3Stacy16/01/200701/06/1968Stacy16/01/2007Hire Date
4Derek10/07/201614/07/1975Jose18/01/2018Hire Date
5Martin21/09/201716/08/1982Jose13/01/1995Birth Date
6Jose18/01/201813/01/1995Peter13/01/1994Birth Date
7Peter26/11/201713/01/1994
8Lance25/02/201801/02/1995
9Judith01/04/201815/03/1982
10
Lists
Cell Formulas
RangeFormula
F3:H6F3=LET(d,EmpMstr[[Hire Date]:[Birth Date]],m,MONTH(TODAY()),HSTACK(TOCOL(IF((MONTH(d)=m),EmpMstr[Employee ID],x),2),TOCOL(IF((MONTH(d)=m),d,x),2),TOCOL(IF((MONTH(d)=m),EmpMstr[[#Headers],[Hire Date]:[Birth Date]],x),2)))
Dynamic array formulas.
Thanks Fluff, im receiving an #NAME? error though. It seems that TOCOL() and HSTACK() is not yet updated in my 365. I wonder if there is other formula approach to solve it. Thank you
 
Upvote 0
An alternative is to use Power Query and build a parameter query that you will look up the particular month.
1. Load your data table to the PQ editor
2. Use the following Mcode

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Hire Date", type date}, {"Birth Date", type date}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Employee ID"}, "Attribute", "Value"),
    #"Inserted Month Name" = Table.AddColumn(#"Unpivoted Other Columns", "Month Name", each Date.MonthName([Value]), type text),
    #"Filtered Rows" = Table.SelectRows(#"Inserted Month Name", each ([Month Name] = Table3)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Month Name"})
in
    #"Removed Columns"

Create a new table in Excel that looks like the following with the second line a validation input of the month name

Month
January


Then apply the following Mcode to this new table

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    Month = Source{0}[Month]
in
    Month

Once both codes are in place, then close and load your first query to an Excel table. The result should look like the following

Employee IDAttributeValue
StacyHire Date1/16/2007
JoseHire Date1/18/2018
JoseBirth Date1/13/1995
PeterBirth Date1/13/1994
 
Upvote 0
An alternative is to use Power Query and build a parameter query that you will look up the particular month.
1. Load your data table to the PQ editor
2. Use the following Mcode

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Hire Date", type date}, {"Birth Date", type date}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Employee ID"}, "Attribute", "Value"),
    #"Inserted Month Name" = Table.AddColumn(#"Unpivoted Other Columns", "Month Name", each Date.MonthName([Value]), type text),
    #"Filtered Rows" = Table.SelectRows(#"Inserted Month Name", each ([Month Name] = Table3)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Month Name"})
in
    #"Removed Columns"

Create a new table in Excel that looks like the following with the second line a validation input of the month name

Month
January


Then apply the following Mcode to this new table

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    Month = Source{0}[Month]
in
    Month

Once both codes are in place, then close and load your first query to an Excel table. The result should look like the following

Employee IDAttributeValue
StacyHire Date1/16/2007
JoseHire Date1/18/2018
JoseBirth Date1/13/1995
PeterBirth Date1/13/1994
Thank you alansidman
 
Upvote 0
Thanks Fluff, im receiving an #NAME?
Ok, how about
Fluff.xlsm
ABCDEFGH
1
2Employee IDHire DateBirth DateEmpDateHeader Name
3Stacy16/01/200701/06/1968Stacy16/01/2007Hire Date
4Derek10/07/201614/07/1975Jose18/01/2018Hire Date
5Martin21/09/201716/08/1982Jose13/01/1995Birth Date
6Jose18/01/201813/01/1995Peter13/01/1994Birth Date
7Peter26/11/201713/01/1994
8Lance25/02/201801/02/1995
9Judith01/04/201815/03/1982
Lists
Cell Formulas
RangeFormula
F3:H6F3=LET(d,EmpMstr[[Hire Date]:[Birth Date]],m,MONTH(TODAY()),c,COLUMNS(d),s,SEQUENCE(c*ROWS(d),,0),xa,INDEX(EmpMstr[Employee ID],INT(s/c)+1),xb,INDEX(d,INT(s/c)+1,MOD(s,c)+1),xc,INDEX(EmpMstr[[#Headers],[Hire Date]:[Birth Date]],MOD(s,c)+1),FILTER(CHOOSE({1,2,3},xa,xb,xc),MONTH(xb)=m))
Dynamic array formulas.
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,973
Members
448,933
Latest member
Bluedbw

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