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 am attempting to generate an email containing a graph generated in R and a simple message. I have this working completely for a single carrier's data. However, this is not scaling with multiple carrier's data in my input. All of the data is feeding into the R and email tools at once, combining into a single output. What I want is a separate output for each carrier. That's why I have been researching some sort of iterative solution the past couple of days.
I have implemented batch macros in the past but they write out from an Output tool using a Full Path field. When I try to use the same setup here (by breaking up the initial data set into Excel sheets or separate files), the dynamic input or batch macro ends up recombining the data, leaving me back at square one. I don't know if that's not the approach needed here or if I am implementing incorrectly.
Is it possible to have an input (ideally a single file, but I could do a directory or a file with Excel sheets or even a Filter) iterate through one criteria at a time (Carrier, Key ID, etc) to restrict the data that flows downstream into an R and an Email tool?
I've taken your workflow and converted the graph and email part to a batch macro
The top input into the macro is the unique list of Carriers. The bottom one is what originally went to the Need To Iterate container.
Within the macro, all the magic happens here.
The input labelled "Input" is the data stream. The one labelled "Control" is the list of Carriers. This macro is configured as a batch macro, meaning that the entire Input dataset will be processed once for every entry in the Control. The Action tool called "Update Value" modifies the Select that it's connected to and replaces ABCD with the next value from the control list. the rest of your "Need to Iterate" is the same except for the Email tool. I put it in it's own disabled container for testing purposes and I added a Message tool to let me know which iteration I was in.
Note that this could be accomplished without the Macro by modifying the R code to return one graph per carrier and configuring the email tool to send to email address contained in [email]. Unfortunately my R-fu is not strong enough to make the modification in the code.