This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
I have recently overcome a challenge, whereby I wanted to give the end user of an analytical app the ability to choose their aggregations, allowing our line of business analysts to ask additional questions of our data, without needing additional input from my team. As there doesn't seem to have been anyone else post about this in the past, I thought to share how I did it. I will be using the Tableau Super Store data to illustrate below.
At a high level, I need to take the tree input from the user, convert it to raw XML instructions to insert into the summarise tool of the final workflow, and then return the results.
Allows a field to be selected and an aggregation type or types. Need to use a macro to develop the tree structure.
Tree Build Macro. Takes a field list, and uses a base input to append aggregations to each field and ultimate outputs the Tree build structure as below
Now that the file is built, we can then use it as the data source for the Tree Macro input
To take the tree input and send to the Summarise tool we have to edit the Raw XML of the summarise tool. We then need to convert the tree tool output into the XML for the summarise tool, To do this I have used another macro
Tree Output To Summarise XML The tree output the key's select all in the one field with new lines separating, so we first split out to rows on the new line (\n) character. Then using the tree.csv output from the tree build macro we go through and build up the Field and Action instructions to give to the summarise tool which are then concatenated into the one tool to flow into the final macro which holds the actual data workflow.
Workflow Batch Macro With all of the XML instruction built, we then need to figure out how we can send a data flow direct into an update tool, this is the part that had me stumped for quite a while, however with a batch macro we can achieve that with a control parameter. As we are only sending one record into the batch macro it will only execute once.
Connect the control parameter to the summarise tool and instruct the action to update the Raw XML then output the data, either into the original app, or a file.
Lets see how it works! Lets group by customer segment, and sum Profit
If you would like to get further under the hood of this, I have attached a sample app for you to pull apart