First of all, thank you for the excellent statement of the problem with sample data and desired output. So, part of Badge is coded as level, and part of it as type. You want to sort the badge by le...
See more...
First of all, thank you for the excellent statement of the problem with sample data and desired output. So, part of Badge is coded as level, and part of it as type. You want to sort the badge by level, take the highest level in each type and the latest expiration date. Correct? Here you go | eval type = split(Badge, "_")
| eval level = mvfind(mvappend("Novice", "Capable", "Expert"), mvindex(type, -1)) + 1
| fillnull level
| eval type = mvindex(type, -2)
| eval expire_ts = strptime(ExpireDate, "%m/%d/%y")
| sort - level, expire_ts, + "Last name" "First name"
| dedup Domain, "First name", "Last name", Email, type
| table Domain, "First name", "Last name", Email, Badge, ExpireDate Your sample data gives Domain First name Last name Email Badge ExpireDate jkl.com brandy duggan brandy.duggan@jkl.com Sell_Expert 9/5/24 mno.com lisa edwards lisa.edwards@mno.com Sell_Expert 12/6/23 mno.com lisa edwards lisa.edwards@mno.com Renew_Deploy_Capable 8/1/24 def.com andy braden andy.braden@def.com Deploy_Capable 1/3/24 abc.com allen anderson allen.anderson@abc.com Renew_Sell_Novice 10/3/24 ghi.com bill connors bill.connors@ghi.com Sell_Novice 10/17/23 I'm not sure why your desired output doesn't use the "Renew" prefix. If I understand it correctly, "Renew_" means that the badge has yet to be renewed. But if you want to get rid of it, just add: | eval Badge = replace(Badge, "Renew_", "") Here is an emulation that you can play with and compare with real data | makeresults format=csv data="First name,Last name,Email,Domain,Badge,EarnDate,ExpireDate
lisa,edwards,lisa.edwards@mno.com,mno.com,Sell_Novice,5/22/22,5/22/23
lisa,edwards,lisa.edwards@mno.com,mno.com,Deploy_Novice,5/27/22,5/27/23
andy,braden,andy.braden@def.com,def.com,Deploy_Novice,11/10/22,11/10/23
allen,anderson,allen.anderson@abc.com,abc.com,Sell_Novice,11/18/22,11/18/23
andy,braden,andy.braden@def.com,def.com,Deploy_Capable,1/3/23,1/3/24
bill,connors,bill.connors@ghi.com,ghi.com,Sell_Novice,10/17/22,10/17/23
brandy,duggan,brandy.duggan@jkl.com,jkl.com,Sell_Novice,7/6/23,7/6/24
lisa,edwards,lisa.edwards@mno.com,mno.com,Sell_Capable,7/24/22,7/24/23
lisa,edwards,lisa.edwards@mno.com,mno.com,Deploy_Capable,8/20/22,8/20/23
brandy,duggan,brandy.duggan@jkl.com,jkl.com,Sell_Capable,8/10/23,8/10/24
brandy,duggan,brandy.duggan@jkl.com,jkl.com,Sell_Expert,9/5/22,9/5/24
allen,anderson,allen.anderson@abc.com,abc.com,Renew_Sell_Novice,10/3/23,10/3/24
lisa,edwards,lisa.edwards@mno.com,mno.com,Sell_Expert,12/6/22,12/6/23
lisa,edwards,lisa.edwards@mno.com,mno.com,Renew_Deploy_Capable,8/1/23,8/1/24"
``` data emulation above ```