I fully concur with
@Excel Wizard . You have sacrificed too much for the dubious option of merging a few cells, starting with needing to employ computationally expensive and largely obsolete methods of generating dynamic ranges.
I would tend to use XLOOKUP rather than the INDEX/XMATCH combination to return a field from a table but there is not much to choose
= UNIQUE( XLOOKUP(D3, Table1[#Headers], Table1) )
If you really do wish to persist with your present strategy, the Name "function" can be calculated using the old EVALUATE() function. The catch is that EVALUATE does not work on the grid; it must be called from a formula within a defined name.