SOLVED
Home

Filter row if another row exists below

%3CLINGO-SUB%20id%3D%22lingo-sub-807606%22%20slang%3D%22en-US%22%3EFilter%20row%20if%20another%20row%20exists%20below%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-807606%22%20slang%3D%22en-US%22%3E%3CP%3ETricky%20filter%20help%20needed%2C%20was%20hard%20enough%20to%20even%20search%20for.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20i%20have%20is%20a%20table%20of%20employees%20who%20are%20entering%20and%20leaving%20the%20building.%20What%20i%20need%20to%20do%20is%20get%20a%20list%20of%20employees%20who%20are%20IN%20the%20building%2C%20so%20basically%20removing%20them%20from%20the%20list%20if%20they%20are%20marked%20as%20OUT%20and%20not%20IN%20again.%20This%20is%20so%20HR%20can%20see%20who%20is%20in%20the%20building%20right%20now.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20table%20looks%20like%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EID%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BTimeGenerated%26nbsp%3B%20%26nbsp%3B%20UserName%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Action%3C%2FP%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3E2671059%3C%2FTD%3E%3CTD%3E16%2F08%2F2019%209%3A34%3C%2FTD%3E%3CTD%3EJoe%20Bloggs%3C%2FTD%3E%3CTD%3EWest%20Door%20OUT%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2671056%3C%2FTD%3E%3CTD%3E16%2F08%2F2019%209%3A26%3C%2FTD%3E%3CTD%3EJane%20Fonda%3C%2FTD%3E%3CTD%3EWest%20Door%20IN%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2671053%3C%2FTD%3E%3CTD%3E16%2F08%2F2019%209%3A19%3C%2FTD%3E%3CTD%3ECorey%20Feldman%3C%2FTD%3E%3CTD%3EWest%20Door%20IN%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2671050%3C%2FTD%3E%3CTD%3E16%2F08%2F2019%209%3A18%3C%2FTD%3E%3CTD%3EJoe%20Bloggs%3C%2FTD%3E%3CTD%3EWest%20Door%20IN%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2671047%3C%2FTD%3E%3CTD%3E16%2F08%2F2019%209%3A18%3C%2FTD%3E%3CTD%3EJane%20Fonda%3C%2FTD%3E%3CTD%3EEast%20Door%20OUT%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2671044%3C%2FTD%3E%3CTD%3E16%2F08%2F2019%209%3A17%3C%2FTD%3E%3CTD%3EJane%20Fonda%3C%2FTD%3E%3CTD%3EWest%20Door%20IN%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20i%20would%20need%20to%20get%20a%20filtered%20list%20showing%20Jane%20Fonda%20and%20Corey%20Feldman%2C%20as%20Joe%20Bloggs%20most%20recent%20action%20was%20to%20leave%20and%20therefore%20not%20in%20the%20building.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-807606%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-807686%22%20slang%3D%22en-US%22%3ERe%3A%20Filter%20row%20if%20another%20row%20exists%20below%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-807686%22%20slang%3D%22en-US%22%3E%3CP%3EHI%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F393225%22%20target%3D%22_blank%22%3E%40Erron00%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20achieve%20required%20filter%20by%20adding%20a%20support%20column%20and%20putting%20below%20formula%20in%20it%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%230000FF%22%3E%3DRIGHT(INDEX(%24D%242%3A%24D%247%2CMATCH(MAX(INDEX(%24B%242%3A%24B%247%2CMATCH(C2%2C%24C%242%3A%24C%247%2C0)))%2C%24B%242%3A%24B%247%2C0))%2C3)%3C%2FFONT%3E%3C%2FP%3E%3CP%3EIf%20you%20select%26nbsp%3B%3CSPAN%3EJoe%20Bloggs%20it%20will%20show%20him%20out%20in%20column%20E.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20445px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F127210i89227F2E1881C8AB%2Fimage-dimensions%2F445x48%3Fv%3D1.0%22%20width%3D%22445%22%20height%3D%2248%22%20alt%3D%22clipboard_image_1.png%22%20title%3D%22clipboard_image_1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EA%20sample%20file%20is%20also%20attached%20for%20your%20reference.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EPlease%20let%20me%20know%20if%20it%20works%20for%20you.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ETauqeer%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-807973%22%20slang%3D%22en-US%22%3ERe%3A%20Filter%20row%20if%20another%20row%20exists%20below%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-807973%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F393225%22%20target%3D%22_blank%22%3E%40Erron00%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20observe%20that%20your%20data%20is%20sorted%20by%20time%20of%20the%20action.%26nbsp%3B%20Therefore%20you%20simply%20need%20to%20search%20for%20the%20first%20occurrence%20of%20each%20UserName%20in%20the%20table%20and%20return%20the%20associated%20Action.%26nbsp%3BFor%20a%20Dynamic%20Array%20version%20of%20Excel%20the%20list%20of%20distinct%20names%20is%20given%20by%20the%20formula%20'%3CSTRONG%3EUserName%3C%2FSTRONG%3E'%20that%20refers%20to%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3D%3CFONT%3ESORT(%20UNIQUE(%20EntryLog%5BUserName%5D%20)%20)%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CFONT%3Ewhere%20the%20structured%20references%20are%20given%20by%26nbsp%3B%20converting%20the%20data%20to%20an%20Excel%20Table%20that%20I%20have%20named%20'%3CSTRONG%3EEntryLog%3C%2FSTRONG%3E'.%20%26nbsp%3B%3C%2FFONT%3E%3CFONT%3EFor%20a%20traditional%20version%20of%20Excel%20such%20a%20list%20can%20be%20created%20manually%20with%20little%20inconvenience.%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%3EThe%20last%20action%20for%20each%20person%20is%20given%20by%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CFONT%3E%3D%20INDEX(%20RIGHT(EntryLog%5BAction%5D%2C3)%2C%20%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CFONT%3EMATCH(%20UserName%2C%20EntryLog%5BUserName%5D%2C%200%20)%20)%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CFONT%3EWith%20traditional%20Excel%20this%20column%20would%20be%20used%20to%20filter%20the%20list%20of%20distinct%20names.%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EW%3CFONT%3Eith%20DA%2C%20however%2C%20this%20can%20be%20simplified%20to%20create%20a%20filtered%20list%20of%20staff%20currently%20on%20site%20directly%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CFONT%3E%3D%20FILTER(%20UserName%2C%20%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CFONT%3EINDEX(%20RIGHT(%20EntryLog%5BAction%5D%2C%202%20)%20%3D%20%22IN%22%2C%20%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CFONT%3EMATCH(%20UserName%2C%20EntryLog%5BUserName%5D%2C%200%20)%20)%20)%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Erron00
Senior Member

Tricky filter help needed, was hard enough to even search for.

 

What i have is a table of employees who are entering and leaving the building. What i need to do is get a list of employees who are IN the building, so basically removing them from the list if they are marked as OUT and not IN again. This is so HR can see who is in the building right now.

 

The table looks like this:

 

ID               TimeGenerated    UserName          Action

267105916/08/2019 9:34Joe BloggsWest Door OUT
267105616/08/2019 9:26Jane FondaWest Door IN
267105316/08/2019 9:19Corey FeldmanWest Door IN
267105016/08/2019 9:18Joe BloggsWest Door IN
267104716/08/2019 9:18Jane FondaEast Door OUT
267104416/08/2019 9:17Jane FondaWest Door IN

 

So i would need to get a filtered list showing Jane Fonda and Corey Feldman, as Joe Bloggs most recent action was to leave and therefore not in the building.

2 Replies

HI @Erron00 

 

You can achieve required filter by adding a support column and putting below formula in it:

 

=RIGHT(INDEX($D$2:$D$7,MATCH(MAX(INDEX($B$2:$B$7,MATCH(C2,$C$2:$C$7,0))),$B$2:$B$7,0)),3)

If you select Joe Bloggs it will show him out in column E.

clipboard_image_1.png

A sample file is also attached for your reference.

 

Please let me know if it works for you.

Tauqeer

 

 

Solution

@Erron00 

I would observe that your data is sorted by time of the action.  Therefore you simply need to search for the first occurrence of each UserName in the table and return the associated Action. For a Dynamic Array version of Excel the list of distinct names is given by the formula 'UserName' that refers to

= SORT( UNIQUE( EntryLog[UserName] ) )

where the structured references are given by  converting the data to an Excel Table that I have named 'EntryLog'.  For a traditional version of Excel such a list can be created manually with little inconvenience.

 

The last action for each person is given by

= INDEX( RIGHT(EntryLog[Action],3),

MATCH( UserName, EntryLog[UserName], 0 ) )

With traditional Excel this column would be used to filter the list of distinct names.

 

With DA, however, this can be simplified to create a filtered list of staff currently on site directly

= FILTER( UserName,

INDEX( RIGHT( EntryLog[Action], 2 ) = "IN",

MATCH( UserName, EntryLog[UserName], 0 ) ) )

 

 

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies