# Elegant way to return first non-Missing column in Dataset

I have a Dataset[] with some data and a TON of columns. Each row contains several columns for dates, which contain DateObject values, but they aren't always populated. If a value is Null, I've replaced it with Missing[] for a) prettier display in Dataset visualization, b) to allow use of MissingQ and DeleteMissing.

Here's my question. I am trying to get a single definitive date for each row based on the first non-Missing value. It's possible that ALL values will be missing. In that case either nothing needs to be returned or a Missing["No date"] is fine.

What I have so far is very ugly and crude, and I'm wondering if there's a more elegant way to do this, that simply escapes me for now?

Flatten[
Take[ DeleteMissing@#, UpTo[1] ]& /@
Normal@Values@encounters[ All,
{"ArriveDTS", "EstimatedArriveDTS", "RegistrationDTS",
"DischargeDTS", "DepartDTS", "EstimatedDepartDTS",
"PreRegistrationDTS"}
]
]

• SelectFirst[Not @* MissingQ]? Apr 20, 2017 at 0:48
• @Pillsy Please add as an answer. That worked wonders! Thank you! Finished product: encounters[All, SelectFirst[Not@*MissingQ]@*KeyTake[{"ArriveDTS", "EstimatedArriveDTS", "RegistrationDTS", "TriageDTS", "InpatientAdmitDTS", "AssignToLocationDTS", "DischargeDTS", "DepartDTS", "EstimatedDepartDTS", "PreRegistrationDTS"}]] Apr 20, 2017 at 1:47

The SelectFirst function does exactly what you want. As you note in your comment ( :) ), this will work:
encounters[All, SelectFirst[Not@*MissingQ]@*KeyTake[{"ArriveDTS",