How to make a dynamic filter by a list?

Hi TW-Experts,

inspired by the dynamic filter discussions here Dynamic Filters - Discussion - Talk TW and by the great solution from @Scott_Sauyet to create a filtered table here Multi level depending tags? - Discussion - Talk TW I developed it further and set up an example here Example on Tiddlyhost.

Now I want to change the hard coded solution of a filtered table from @Scott_Sauyet here Filter to a generic one to use them for example here Asset and here Department or here Location and also in future projects.

I have this procedure Filtered Table and the selected values are stored in fields.
I try to build a filter like this structure (this not code!!!) but I fail always with the syntax for variable handling and replacement and need help or other inspiration to get this solved.

<!-- THIS NOT CODE -->
<$let
      config=<<currentTiddler>>
      Master_query = `[tag[AssetPlacement]!has[draft.of]] '
      Master_filter = ':filter[[${ [<config>get[XXX]] }$]match{!!YYY}' 
      query=Master_query
      filterexpression=""

<$list filter="[enlist<fields>]" variable="field"> 
   <$let name="my_fieldname" value={{{ [<field>addprefix[My_]] }}} 
   >
<!-- if my_fieldname is not empty add it to the filterexpression -->
<!-- -->
<!-- filterexpression == Master_expression [search&replace:"XXX", <field> ] -->
<!-- filterexpression == filterexpression [search&replace:"YYY", <my_fieldname> ] -->
<!-- query == query + filterexpression -->

<$list filter=<<query>> >
 <tr>
  <$list filter="[enlist<fields>]" variable="field">
    <td>
      <$text text={{{ [<subfield>get<field>] }}} />
    </td>
  </$list>
 </tr>
</$list>

Any help, any idea, any inspiration is welcome
Thank you
Stefan