Transcript for:
Iteratoren und Aggregatoren in make.com

what's going on guys welcome to another video on our course make.com but for people who want to make real money and it is a BAL me minus 20 uh degrees or so in Calgary I thought I would put on my favorite winter sweater and record a video today on iterators and aggregators this is going to be everything that you need to know in a practical sense to succeed with iterators aggregators and make.com I find way too many people diving way too deep into this for basically no reason because you're only ever going to use iterators like 10 or maybe 15% of the time um so we're going to focus on like a real practice iCal application for an accounting firm and we're just going to try and make this as simple as possible uh I'm going to not tell you but I'm going to show you how they work and then hopefully you're going to pattern match this into your own flows and then do something cool and make a bunch of money with it so if that sounds like something you're interested in stay tuned and let's get into it okay so not going to lie I did record an entire video for about 35 minutes right before I did this and then I realized that uh OBS was not on so I'm going to be doing this again and hopefully it's going to be way higher quality than it was before what we're going to be doing here is I have an example spreadsheet set up and we're going to pretend that we're building out a flow for a client that wants maybe some accounting Automation and it's going to be a really simple flow I'm going to keep it as dumb as humanly possible because the focus of this is going to be on how to use iterators and aggregators but essentially what we want to do is just like once a month we want to send the client an email just telling them what their net uh cach in was and the way that we're going to do this is we're basically going to plug this into a make.com scenario and then we're just going to add up everything in the amount column here so you know classic spreadsheet right you have the name of the transaction uh you have like the date added this is in like date time format which we'll touch on and then you also have the amounts all we're going to be doing is just going to be summon this up and I mean like Google Sheets already does this for you look at the bottom well you probably can't see because my face is there but in the bottom right hand corner of the screen like when you Mouse over stuff in Google Sheets it literally shows you like summary value uh so right now it's saying the is 28774 for instance um so we're basically going to be doing this and then we're just going to like attach this to a one-step email and that email is just going to be sent out to a hypothetical business owner and just say hey man in the last month you made X dollar great so that's going to be the whole idea and that's uh that's what we're building out now again I've already built this flow out so I'm just going to create a new one we're just going to pretend I'm building it from scratch and I'm going to pay close attention to my camera to make sure that that doesn't happen again okay so what I have here is a new make.com scenario I'm going to open up Google Sheets because we're going to be pulling the data from Google Sheets and then the module that I'm looking for here is called search rows right down there and what we're going to do is after I select the correct account um I'm going to find the spreadsheet that I'm using which in this case is specifically called example spreadsheet there you go we got it and then I'm going to grab the sheet name sheet name is just the text down here uh the table does contain headers leave everything else as default uh we'll work on a filter in a moment and then sort order a sending order by and then we're not going to put anything for maximum number of return rows if you don't put anything in there it'll just select all of them and then we are going to run it and now we see the first parts of iterators and aggregators so what a lot of people think is they think that and aggregators they're separate modules that uh you know you can kind of optionally put into a flow this would be your iterator this would be your aggregator notice how they have these fancy diagrams where with the iterator one thing's coming in five things are coming out with the aggregator five things are coming in one thing's coming out in the reality in reality in make.com many modules already have iterators and aggregators built into them and so usually any module with the name search or list or filter file find U anything like that actually already has an iterator built into it so you don't need to add another iterator and the way that you find out is if you click on the model output module output rather and if there is more than one bundle that is output from that module then this is an iterator module and so all that that means is basically if we were to add a scenario a or a module after this so let's just add a set multiple variables the variable is just going to be amount and then the variable value is just going to be amount all that having multiple bundles means is if I click run once pay attention to the bubbles above every module the Google Sheets module run one runs once but then it because it outputs four different bundles everything after that is running four times and so we're consuming for operations this is for module executions and uh you'll also see that there are different operations here so like this it's four operations every every time you have multiple bundles coming in as an input to something um you're going to run it basically however many times the number of bundles that have come in and so you can think of an iterator is basically anything that takes in one bundle and then puts out multiple bundles so if we go down that diagram kind of see why this makes sense now right because we have an arrow coming in with just one bundle and then it's outputting a bunch of different bundles and the really important part about iterators is that basically for every bundle that you are then putting as output every other subsequent module in the scenario is going to run for that bundle and for any other bundles that you're sticking in now the reason why this is important is because if you're not careful when you use iterators gratuitously you can consume a ton of operations I've seen flows and I've built flows that unfortunately consume anywhere from like 50 to 500 operations per execution you can imagine now if you're trying to run that every day well there's the whole you know 20 or $30 a month make plan right so I usually don't actually like using iterators in aggregators for the sole reason that it becomes very operationally expensive to maintain and there are usually ways that you could just chop up a big scenario into three or four tinier scenarios to achieve the same thing without having to do all of that so that's my piece a lot of people would probably disagree with me on but hey now um cool so we have basically one bundle coming in as input and then we have four different bundles coming out and what you'll find is if you access a variable in a subsequent module that variable will change for every run so in the first run it's going to go and stick in 3583 because we're sticking in the amount here right so the first run is going to be 3583 second run is going to be 194. 5 Third Run is going to be 9591 the fourth fourth run is going to be 38.5 it's a different uh the variable is different every time because we're basically running this a new and let's say I wanted to just add another module here to really drive this home let's just say that we have another variable that we're calling double in a subsequent module and then we're just multiplying this by two then I run this again notice how we have three modules but this is nine whole executions we ran once we got four bundles as output to the first iterator module and then we had four runs for the second module runs for the third module so be careful when you're making uh flows with a lot of iterators and a lot of aggregators so anyway that's that first scenario when you're just using a built-in iterator um what I want to do now is I actually want to take a little bit of data and then I want to I want to iterate it um just outside of this just so you guys can see what an iterator like the actual iterator module does and so I'm just going to use this set multiple variables as my flow and then I'm just going to call this example array and what I'm going to do is I'm just going to use I'm just going to build a really simple array and then I'm going to show you how if your module doesn't have iterator functionality built in but you want to give it iterator functionality uh you can just use the iterator module super simple and super easy so what I'm going to do uh this is just a quick and dirty way to like make an array uh you can use a bunch of different uh functions to make arrays all you do is you go over here to the array tab uh but I know a really simple function is just split and then as you can see it actually shows that exactly as an example so I'm just going to do this and then I'm going to separate by comma and so what this is going to do is this is going to take in one string as an input and then the output of this is going to be three different items in an array and so I'm going to click okay and going to run this puppy and then now as you can see we had one variable as the input well I guess this uh is counting the input and the output but anyway we had a string that was like John George Paul all separated by commas and then the output of that is this array that that is indexed uh the first entry is John the second entry is George and then the third entry Paul so pretty cool what I want you guys to think about iterators is doing is basically an iterator will just take an array and then turn that into various bundle uh bundles and then an aggregator will take a bunch of bundles and they'll just turn that into an array it's a really simple and easy way of kind of conceptualizing what these two things are doing so um great now that we have this and we have an array why don't we iterate over it the way to do so manually if you don't have a built-in functionality to your module is go over here to tools and then click iterator you need to Define an array as your source and so the array that we're defining as our source is going to be this example array be careful when you select this what you need to do is select the variable with uh square brackets uh and no number in between otherwise you're selecting an entry inside of the array but we actually just want to select the whole array and then to make this super simple I'm just going to use a set multiple variables module and I'm just going to add um another example variable and then I'm just going to set it to as you'll see uh when you use an iterator you'll have a couple of default variables that are always accessible to you total number of bundles bundle order position and you'll also have the value of whatever it is that we're selecting and if that doesn't make sense this will so we had one um this ran one time the output was an array with three items John George and Paul we then fed that into an iterator the iterator ran once because its job is to basically build a bundle structure you can think of it as it doesn't have to run multiple times only runs once does its job as the input to this iterator we had that array with three items as the output we turn that array into three separate bundles and so what that means is now anything after this iterator is going to run however many bundles we have and that's exactly what happened with this final module 6 it ran three times the input to the first time we're just setting a variable here was the first item or the first bundle value coming out of that uh iterator module which in that case was John the second one is probably going to be George and the third one hopefully will be Paul there you go so yeah that's how iterators work in a nutshell and how you can incorporate your own iterator functionality into it uh but why the hell am I talking about all this I thought I was going to build something that is business ready and you know something youd probably do for yourself for your clients so let's get into that by learning a little bit about the flip side of an iterator which is called an aggregator the simplest way to understand an aggregator is to go open a make scenario get like a Google Sheets module like this um build out your own Google sheet for whatever functionality you want and then go down here to this purple uh tools button and then as opposed to the flow control button with the array aggregator much simpler way to understand it go to the tools and then scroll down to numeric aggregator here and I'm going to use this I'm going to show you exactly why this works and how this works um basically what we'll do is we're going to feed in every bundle as an input to this numeric aggregator module so the source module is just going to be whatever the previous module is in this case we only have two modules so we can only select the Google Sheets module but just always select the the earliest module the one that is outputting all of the bundles that you want and then you'll see here for the numeric aggregator module you can select from a number of functions and so these are pre-built we could do an average we could do a sum we could do a count we could select the max value the Min value right we have a lot of options here but it keep it simple I'm just going to use sum and then the value that we're going to stick in is going to be whatever value that we want like num generally aggregated and so in my case it's the amount and just check out the magic that happens when I stick this in that's what she said uh as output we have the four bundles uh as we had previously right and then all of those went into the numeric aggregator and then look at what happened we fed in these four bundles as input and then what happened the output just summed them all and at the end we only get value called result and so the way that an aggregator works is again it's just a flip side to the iterator we have multiple bundles coming in and then just like the diagram shows we squash those into a single value coming out you'll also notice that something's Chang graphically in the make UI and this is interesting I don't think too many people understand like the the Nuance behind this but basically uh anytime you have like a gray sort of thing wrapping around a few modules that's because the beginning of that modu uh beginning of that flow beginning of that gray area is an iterator and then the end of that gray are is an aggregator and so because an iterator expands things into a number of bundles and then an aggregator squashes that back into one bundle any modules outside of that Gray Zone can't access anything inside of that except for the output of the final module what do I mean by this well let's make this a little more complex let's say hypothetically we have a set multiple variables module we stuck it in the middle here and then we had a variable that we just called double we're going to grab that amount we're going to do that mathematical operation we did before and then we're going to Auto align these what I want to do is I'm going to sum up the double value instead of the original value and then I'm going to add another multiple variables module here and then I'm just going to leave this as blank for now and then run this once you see that everything is working as expected Google Sheets module ran once set multiple variables module ran four times because this is simply um operating per bu right this isn't an aggregator module or anything and then the aggregator took this as an input and then turned that into one you'll see that the values here double what the previous values were that's sort of to be expected right so the result is as well now let's say we want to add the result and just stick it in this set multiple variables module and we just wanted to like store that information somewhere let's just call this doubled result notice how the only thing accessible to me is a single module which is Tools 7 which is this numeric aggregator I can't actually go back and access anything from from uh Tools 8 and I can't actually access anything from Google Sheets the reason why is because this module is not inside of that gray overlapped sexy area that you know really wants to be in it's not in the exclusive Club um and so the reason why is again because everything in here is like uh it's executing a bunch of times and it's just it would be impossible for you to reference a single value here when the whole purpose of this flow is to squash that into a value over here right this is going to run once everything after this but everything inside of here is going to run as many times as the number of bundles generated by the trigger okay great so why don't we actually use this now to build our summary metrics we're not taking double as input we are taking amount let's run this again for sanity 28774 and actually let's do one more thing first um I added in three values that were in February so 223 2024 224 2024 224 2024 and then one uh value that was from or one row that was from March and the reason why is because I just wanted to teach you guys a little bit of filtering while I was doing this let's say hypothetically for the purposes of our flow that we're building we only want to get dates within the current month you can imagine how maybe we run this flow on the last day of every month and the purpose of this flow is just to take everything from uh the beginning of the month all the way up to the current date or maybe the end of the month and and then just to add all of those entries up and then deliver that as like a cash flow report um so in order to do that uh we'll use this Google sheet search rows module and if you guys remember at the beginning I mentioned that there was a filter section so we're going to implement a couple of filters now to do that so I'm going to be filtering by date added and what I basically want to do is I want to select only the entries between February the 1st and then uh the last day of the month the way that you do that is in filters you can scroll down uh there are basic operators text operators numeric operators what we're interested in our daytime operators so uh I'm going to select later than or equal to and what I'm going to do is I'm going to attempt to define a date and I want that date to be the 1 of February basically the way that you do that is you head over here to the date and time Tab and then you make use of the now variable and then you also make use of the set date variable what this basically does is it takes in the current date which is now um make has a really complicated date string if you check out the red text in there like 2016-12-28 t163 06372 Z that's its own like internal representation of what a date time is but what what now does is now just gets the current date time so now is like 234 February the 27th 2024 right um it would just turn that into whatever this long object is and then all the other functions in this date tab they they know how to manipulate those variables uh those that format of date time object essentially and so one of the functions is called set date and it basically takes as input that date time object and then it allows you to set the date of the month based off that date and so if you feed it in February the 27th and you say I want you to set the date to be the first it'll just um change the date to be the first essentially so yeah that's that um and let me just run this right now just to show you guys what that comes out to in practice if you select the module and then you go to filter it'll show you the operators that you've essentially created here and you'll see how um this o variable stands for the the operator so I'm looking at the date operator and I'm checking to see which dates are greater or equal to and then this B here is the actual value that you're feeding in is your filter so this is the source of Truth February the 1st 2024 1:35 p.m. uh this isn't like super accurate but I'm not going to worry too much about fixing it ideally though you can imagine if you were trying to build out like a precise flow you'd want it to start at like 12:00 a.m. that day uh but it's aside the purposes of this so I'm just going to move forward and then I'm going to build out another filter and that filter is going to be um for the end of the month so I'm going to go find another datetime operator we're going to say earlier than let's just do earlier then and then let's make this March the 1st how you do that is you go back to the datetime operator and then you do add uh months so add months set date and then add one month to that and so this is going to take the date that we had previously it's just going to add exactly one month so it's going to go from February to March and then what we're going to look at is we're going to look at entries that are later than February the 1st and then earlier than March the 1st and there's a little bit more Nuance there this is later than or equal to February the 1st and then this is earlier then March the 1st so technically it should be February the 1st inclusive all the way up to March the 1st excluded um but I'm not going to worry too much about the Nuance but let's just check out that filter and see how it operates um since since three of these were in February and then one of these were in March they should only operate three times and that's what happened so we only selected the ones that were in February so it looks like the filter is working and then we took those values and then we used the numeric aggregator to sum them up to 32624 what I'm going to do now is I'm going to write an email to myself talking about how great I am now this would be the email maybe that you're writing to your EXA client or maybe or maybe yourself if you're running a business and you want some type of summary metric I'll leave it at drafts for now write the email address in question I'll say your monthly report is within I'll say hi um I'm using HTML so I'm going to use these BR tags to space it out a little bit um your monthly cash flow let's call this a cash flow report hi your cash flow for the month of let's have make get the date so let's do now make has another date time function called format date so we can take as input a datetime object which is that long number string thing 2016-12-28 whatever and then we can turn that date time into just natural language like we could make this say February the 27th or something if we wanted to um so that's what we're going to do here we're going to use format date I'm going to take his input now and then I'm going to take his output and I only know this because I work with dates all the time but if you want to like learn more about this head over to tokens for datetime formatting here um it's like a make.com help page and it to shows you which tokens to stick in but I know for sure that I just want to select mmmm that'll stand for the month so that'll grab February basically um so your cash flow for the month of February is and then I'm just going to select and then let's say your net cash flow counting up all Revenue line items and subtracting all expense line items for the month of blank is whatever and let's see maybe I can bold this too make it look really nice and sexy uh and then I'm going to add a few more BRS thank you and then we're just going to pretend we're like accounting or something you can imagine you could actually build this out for an accounting firm pretty pretty easily I'm going to run this just to make sure it works um we're back here we in drafts that was from the previous flow that I ran so it'll be this one here yeah there you go uh High your net cash flow for the month of February counting up all revenue land items subtracting all expense l items is this amount thank you accounting great um that is our super simple and easy business use case and then the last thing I'm going to do here just while I have you and you're also interested in what I have to say is I'm going to show you how to use the actual array aggregator module uh which is very similar to what we just did here with the numeric aggregator it's just in green and I really like the color green no it doesn't have um it doesn't have like its own built-in uh function but you can just add that function in later if you want so so okay imagine we have an iterator over here which takes as input one bundle turns it into a bunch of bundles in in our case three but let's say we wanted to um take those three bundles and then sash those back into one value and probably the simplest way to do that is with the example that we provided earlier um let's have two summary functions one will be called doubled amount which will just be amount and then we'll do times two and then one will be called tripled amount and for whatever reason we just we we really want to get these we just need to multiply them by two for God's sake and then we drop in an array aggregator feature and basically what we want to do is we want to we want to run this we want to multiply all of the values by two and then by three and then we want to get all of those values at the end um here's how it works well first things first as the source of the aggregator when you're building out these flows for yourself to keep it simple always use the earliest iterator in the flow what that means is the Google Sheets module here is the earliest iterator in the flow it's the module that defines the number of bundles that are being created so I want to use that as the source of my flow now if I click okay notice what just happened we just added that gray outline and we did it around the Google Sheets module I don't actually know but I feel like if I select this it'll yeah it'll only do it around here so to keep your flows really simple just anytime the bundles start coming out um that's what you want to like encapsulate with your uh with your aggregator of course there are probably going to be a bunch of like make Professionals in the comments being like oh well that's not always true uh I really don't care because I almost never use iterators and aggregators most other people really don't use iterators and aggregator creators and this is probably just the simplest way to keep it all in track in your mind unless you know you do software development or uh computer architecture stuff for a living okay so next is Target structure type uh I select um custom for this all the time and pretty much everybody else will as well so just leave that as is and then the part that causes the for people is this field um aggregated fields and basically the way that it works is so as input we had an array right or like a one bundle and then as output we had four or or sorry three different bundles for this search row module right and so what we're doing is now we're trying to quash that down into a single um item or a single array basically uh so we're just doing the opposite of what we did with the iterator where we turned one array into a bunch of bundles now we're turning a bunch of bundles into one array and what we need is we need for that array to have a bunch of variables basically or values for the stuff that we're interested in having because you can only access the last module in an aggregator which is usually the array aggregator itself um you can select the values that you want to have accessible to you in that last module so what I want accessible to me is I want to be able to access the doubled amount which is here the tripled amount which is here and then I also want to be able to access the transaction name which was here the amount which was also here and then the date added which was here and this is hypothetical you could add as much information as you wanted here all the variables that are accessible I mean in our case it's just a bunch of empty Google Sheets uh columns so it's not really super important but yeah just to give you guys some freedom and then if we run this you'll see what we were expecting to see which is that the iterator runs once the any flows in the middle run the same number of times as the number of bundles and then the aggregator runs once as well and then look at the output of the aggregator the input was three bundles and each of those three bundles just had a bunch of values and these are the values that we selected a moment ago with aggregated fields we have the title or transaction name from here the amount from here and then the the date time from here these are titled weirdly but don't worry too much about that just a Google Sheets convention and then we had the two U variables that we picked from here like doubled amount and tripled amount and you can see that we had this for all three of the the bundles that we fed into this flow then the output is just a single array it's one bundle a single array with three collections inside of it and so we've taken three separate bundles that were all flowing on their own and then we've just quashed those back into a single array which is now the output and now we can do anything that we want with that maybe we want to add I don't know we want to add the um doubled and the tripled amount to get like the five times amount or something and when we run that once you'll see that now everything after the aggregator only is run once I don't really know why that happened oh oh yeah I just uh stuck them next to other I probably should have added a plus but whatever I think you guys get the point okay great so that is how iterators and aggregators work in make.com um I hope you guys enjoyed the business use case and the way that I tried to make it really simple I'll be honest guys you're probably not really going to use iterators and aggregators more than once in any flow if you find yourself building flows and like every single flow is an iterator aggregator just ask yourself if you're building things that are too unnecessarily complex ask yourself if you can just divide that into two or three scenarios instead of just one because usually what happens with these iterators and aggregators is the flows that you build as a result of them are just super unmaintainable and they can just take a boatload of your time all I care about is building Revenue performance systems systems that make money keep money and allow you to keep more of the money that you are making obviously and a big part of that is just the time you're spending maintaining and updating and and and error fixing systems so I like to avoid that as much as possible and I hope that you guys have at least gleaned that from all the other videos in our course thanks so much for watching if you guys got any question questions leave them below as a comment otherwise like subscribe and I'll see you on the next one thanks