Summarizing grouped DataFrame where a group is entirely missing

Thanks for all the discussion. At the end IMO only this solution works as intended:

Or in the original example:

d = @chain begin
      DataFrame(x=rand(12))
      @transform :gr = @bycol repeat('A':'D'; inner=3)
      @transform :x_miss=:gr == 'A' ? missing : :x
    end

function calc(df, vbl, gr, fun)
  safefun(x) = all(ismissing.(x)) ? missing : fun(x)
  outvar = string(vbl)*"_"*string(fun)
  @chain df  begin
    @groupby {gr}
    @combine begin
    {outvar} = (safefun ∘ skipmissing)({string(vbl)}) ## Variant 1 with explicit function
    {outvar*"_2"} = ((x -> all(ismissing.(x)) ? missing : fun(x)) ∘ skipmissing)({string(vbl)}) ## Variant 2 with anonymous function
    end
  end
end

The other solutions don’t work, because I don’t want missing if only few entries are missing or because I want to combine, not `transform``.