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 do a lot of disaggregating of data based on certain characteristics, which generally requires a bunch of summarize tools to be put into the workflow and individually configured. I had an infomercial moment and thought there had to be a better way, which led me to making a macro (more specifically a macro nested in another macro) that would allow me to quickly disaggregate and get counts for a variety of different suggestions. Most of the time I am also adding a higher order disaggregate (e.g., disaggregate based on gender and ethnicity), so I have an interface element that allows me to specify that as well. The problem I am currently running into (and the reason for my post) is that if I don't want a higher order disaggregate and select [None], I get the error "Field names must not be blank" and "a record was created with no fields."
I have deduced that the problem is in my nested macro I am changing one of the fields to be [None] which creates a blank and yields no fields. I have tried as many ways as I can think of to do this within the Alteryx interface, to no avail. I have also included a packaged workflow with sample anonymized data.
Thus my question: is it possible to conditionally remove a "group by" field from a summarize tool within a macro?
I don't appear to be able to open the macro as it has been developed in the latest version of Alteryx but I believe I understand the problem so will attempt to give you a solution anyway.
I believe you want to update the number of group by's within the summerize tool to be inline with the number of fields selected by the user. This is possible but it's a bit less straightforward than you might imagine and it's not common knowledge how to solve this issue.
We can set our list box tool to be in 'Generate custom List' option, which allows us to generate the 'raw xml' that is required for each group by selected by the user. We can then use the 'update raw xml' option in the action tool on our summerize.
In order to identify what the xml should look like it's best to put in a sample configuration and then make sure you have the 'display xml in properties window' option selected in the 'advanced' tab of the user settings.
After playing around with it I realized that if I threw a bunch of variables into it it disaggregates across all of the selected variables. What I need is what is produced by a batch macro - breaking down the same number multiple different ways (e.g., look at the number of males vs females, break down by race, by other group variables independantly).
That being said I think that the macro @BenMoss put together is almost there. I will keep working on this next week :)
Well it seems like the batch macro and a drop down interface with the action set to "Update Select with Multi-select Listbox" are not getting along and that is what is causing a problem. Specifically I am getting an error saying that the control parameter must be mapped to a field (which I had done when making the second macro that encompasses the batch macro).
I have attached another packaged workflow where I am comparing my nested batch macro (which I need in order to get a union like output) with just the batch macro on its own.
The batch macro on its own works as expected, but I cannot get the nested batch macro to work for the life of me. Any and all help is appreciated :)
@BenMoss After walking away from the problem for a few weeks I had a moment of insight and converted your standard macro to a batch macro and then inserted that into a standard macro. I have attached both macro files here.
Thank you again for your help! I didn't have the XML skills to make this work and you are still a lifesaver