Unable to use two different 'Group by' groupings to filter Table data conditionally

Issue #1: I can’t find a way to filter my Bubble DB data in a Table element using the Do a search for and Group By operators with 2 different groupings based on a condition.

Grouping 1 (default, works) – group by “display_application”

Grouping 2 (based on a condition, doesn’t work) – group by “L1”

It’s the same table, the condition is “if a button’s state is yes” then “use Grouping 2” instead of 1.

What I want to achieve – I want my users to use these buttons to change the grouping of the data in the table:

How can do this?

Current solution: Have multiple identical tables on the page with each one having a different grouping as the data source. Then make them visible/invisible based on the conditional. Needless to say this is not ideal from a performance POV.

Issue #2: I will soon switch to calling my data from an API rather than the Bubble DB. Should I have a different set up altogether to achieve this?