The function workspace("xxxxxxxxxxx") doesn't allow a variable so you have to hard code these
You could consider doing this query from within a Azure Monitor Workbook as that allows you to query any selected / visible workspace.
Otherwise using a Logic App or even the api's to enumerate through workspaces