I'm not sure what you are trying to accomplish. You write about "min the first field", do you want MIN(id) for all id/MonthYear that do not have a date?
I'm pretty sure I've misinterpreted you question. Could you please explain what you are trying to accomplish? Please give an example on a normal case and the special case that you are trying to handle.
Plees ekskuse my Swenglish and or Norweglish spelling misstakes
Please look at my previous comment about explaing your issue a bit more. Below are some general tips related to your question, hopefully they can be of help.
If you want to populate a field with an alternative value if the default value is null then you could use the ALT() function. The expression ALT(min(date), max(date),id) Will return the id if min(date) and max(date) returns null.
You can create a date by knowing only year and month using makedate(). E.g. if YearMonth is 201901 you could get the last day of month by the expression below.