Friday Functions | Introduction to Arrays

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to another Friday functions video in this video we're going to give you an introduction to arrays this is for beginners who have getting used to using arrays in flow but it'll also give you a foundation for building on that on this knowledge this is part 1 of 2 part 1 is for beginners and part 2 will be later on in June for more advanced users so let's get started first of all what the heck is over an array an array we see it every day in the real world right it's we make lists right we make our grocery list we make our list of people we love we make our list of all the things that we have to do on the weekend and we make a list of all the videos we have to make for our power absolute flow YouTube community right these are all the ways that we use to organize things together under a topic and so it kind of creates an object of things that we're gonna reuse later to remember what we need to do computers also need lists and a way to organize things so that they can retrieve them later and so the way we define this in computers is that an array is a data structure that contains a group of elements right these elements are normally of the same data type such as a number or a string arrays are commonly used in programming and computer programs to organize data so a related set of values can be easily sorted or searched so very often you'll see people put arrays into an array variable and then they can call that variable later to do any number of things with it okay now thinking again of what the computer views as an array the actual array is very much like a package of variables so right here we see 1 2 3 4 5 boxes all join together in one array ok each of those boxes can contain something that relates to this array the way we identify each box is not real by saying blue box orange box green box any of that we actually named the box is according to their index number and we always start at zero so the first box in this array is index zero and the gray one is index two now an array always has something in it it's never empty like this it will have either a string value in it like in this case we have a string of product names it can have numbers in it in this case you see integers when there's no decimals it's not float its integer when there's decimals we use float we could also have like yes or no zero one values which is boolean or we could nest arrays inside of an array so there's lots of things that can be in an array now when we're working with arrays in flow and we will do this together we can actually create an array of our own just dynamically create an array which we're going to do together and we're going to create an array of these product names and therefore they will end up in this nice little neat package of arrays right here and you can probably tell which one is at index number three so this is where you have to remember that we always start at 0 so 1 2 3 C D s the common data service is sitting there nice and neatly into index number 3 but how do you get these out when you're working inside flow you use advanced expressions so in this case if I wanted to get flow out of as an output in Microsoft flow I could use this expression here that says first and then give me the outputs from the composer array now in this case let's let's call this array compose array but in flow we're actually going to put it in compose action that's going to be named compose array so since it's in a compose action what is the array is really the outputs of that action so in this case we're asked to asking for the first output of the compose array action which is going to have as its as its formula right here the actual array and so the first one will be flow we didn't have to say zero because it's the first one and then the last one will be a I and just we just have to say give me the last one so if we want something other than first or last then we have to reference their actual index number and then we don't use the first or the last function we just use the name and the index number and that will give us back power-ups 0 1 2 and then that's as easy as it can be right now let's get started now couple things to remember before I go into the demo is you will need to add your dynamic content once you have it up there you need to click on the expression tab to make expressions you cannot just type in the outputs of your flow actions when you want to use expressions you have to go to the expression tab and you have to remember to click on the OK or the Update button which is normally over here but you'll click on those and once you click on them they will show in your outputs one big habit I see people make is they will work on their formula and then they'll click somewhere else besides ok and it will all be gone because we don't even save this until you click OK or update if you're making a change so you'll want to validate that after you clicked ok or update you actually see the formula in the inputs before you test ok you want to give this a try I do want to point out that yeah a lot of this will involve in the part 1 and part 2 will involve data operations conditions and variables which I don't know if your work if you've worked with but these are common ones for arrays that we'll talk about later ok let's go over to Microsoft flow I've created a flow with a basic manual button here just to play around and I'm gonna start by creating the array so this one I'm not going to connect to any data I'm gonna create my own array and then we'll connect to data less next right and this is what I'm gonna call compose array because the point of this action right here is actually to create the array so now Here I am I need to make sure I can get over here to the dynamic content and that I click expression now I can type my formula which is create array and I'm going to actually put the same array that we were working on in PowerPoint so it started out with flow is the first element notice as I type the syntax is showing how many objects are in this array alright so I'm gonna do flow and then I'm going to do power bi and then I'm gonna do power apps and notice as I get over to the right and I start losing space it backs it up for me to try to keep my cursor visible right so power-ups and after power-ups I'm going to add C D s and then after C D s I'm going to add AI okay so now that I have those five objects there I'm gonna click OK and you'll see that this drops into that box let's test and see how that worked so I'll just perform the trigger action which is just the button press in this case I don't have any inputs into my button it runs beautifully and here's my array now very important thing about arrays is that in the outputs of your JSON you can always recognize an array because it starts with an open straight bracket and it ends with an open with a closed straight bracket and then in between those brackets is your array and we have the items that we typed and they are indexed invisibly as 0 1 2 3 4 so let's test that out we're going to start with first and last and we'll do the index okay so the first thing I'm gonna do is add another compose now this could be a variable that I'm initializing could be anything I'm using compose just because it's a little easy for me to just get into it I'm gonna go to my expression and here I think I have to start with my dynamic content and you'll see why I want to just kind of show you something interesting so we made our array here so this output right here represents the array so if I click on it and then I hover over it you get what this is in the peek code right maybe we say peek code you can see that the input here is output compose array but sometimes you can use that to help you know what to type in your expression as well okay so I'm gonna close that I'm gonna go back into my expression and from the expression I'm going to where was I gonna do first write f irst which is the function for first it all it needs is a collection I can actually click back into dynamic content and put the output in between those parens and you'll notice when I put it in there it's gonna translate itself to what we saw when we hover it over it alright which is outputs compose array that's all I need so I'm gonna remember to click OK and then I'm gonna hit test and save a test all right so I'm asking for the first part of this array and so if I open this you'll see the first one is flow and does that correct yes it is because the first part of this was flow let's quickly do the last two just so that you don't think I'm lying we're gonna replace the word first with last and we're gonna test oh sorry I did a bad thing notice I didn't click OK so don't go so fast because if you don't click update or okay after you change if a formula it won't save alright so just remember to click update and kind of take an eye peek and make sure it's changed and now you can test ok that's a very common mist especially for people like me who like to hurry up okay so now we've got an array with flow what we looked for was the last one so should we should have a I and we do okay so now here's the slightly tricky one all right if I hit edit here I want the second item in this array so I don't want last which means I'm going to get rid of its its closing / in as well instead I'm gonna open a bracket which will automatically give me both and type the number number two because actually what I want back is power-ups so I'm gonna hit update here and test again and just to remind you I remember how many numbers there are in here cuz I've typed this but if you look at your array power apps is at index two flow is zero power bi is 1 power apps is 2 so if I open the compose you'll see that power apps is what comes out now you're probably fan to yourself Audrey we don't actually sit there and type arrays we get them from real data okay okay I got you so I'm gonna take you back to my flows and open up a situation where I'm actually listing items from an Excel spreadsheet so let me just show you that spreadsheet here it is basically the table is what you see here in blue and black and I added this index that's not in the table it's just to remind you that even though this is bigger right because there are multiple properties in this array each property coming from a different column it's still four and it's still five indexes so 0 1 2 3 4 4 being this entire row is index number 4 okay so let's just quickly look at that I'm just going to test the listing of the items in the table and you'll see if I open this up we'll give it a minute I think it just takes a couple of seconds I open this up takes 4 seconds and I'm gonna copy the JSON out of the body and put it in notepad so we can look at it again just like before the beginning of an array is to start it with a bracket and the end of array is an in bracket so you can immediately tell this is an array beginning bracket interact Beckett now each row of that table represents an object in the array each one having multiple properties from those columns now it gave us some stuff we didn't really need which is Excel friendly stuff but we still get the columns that we wanted there right here so but we have index 0 index 1 index to index 3 and index 4 from our JSON now let's do the same polls that we did before with this more complex data so I'm gonna do compose again and I'm gonna do first now first and last are the same so I won't do both I'll just do first alright again I'm gonna go over to my expression area and I'm gonna do first now in between first I want that array whenever you have a list of items like this the value list of items represents the array when I press that notice it put it in there for me and it put underscores excuse me underscores where the spaces are because we can't have spaces in these expressions and then I'm gonna say okay and let's run a test on this alright run that flow-flow ran successfully if we open this original get items for the list you'll see that the very first object here in this list is the one about checking Dropbox account for new files which is assigned to David and it's completed so that's the one we should get in our output here and we did ok so in this case the input and the output are this because we used a function at the root of the compose right so it's input was the function index and that's what it gave us as an output Azrael all right so that oh let's go find something in the middle so let's get that second index item again again I'm gonna take off first in the front and I'm going to take off the back paren and instead of that back we're in I'm going to open a bracket and type the number to it put the closing bracket in there so I'm asking for index two from this array I'm gonna be sure to click the update first and then I'm gonna run my test okay so what should be - let's take a peek at our OneNote again so this is 0 this first one here this is 1 so we should get this one about alerting security about the new employee for James which is not started all right so let's run our flow and let's see what we get and that's exactly what we got easy peasy all right now the last thing we're gonna do is see if we can pull a certain property out of this okay so I'm gonna hit edit and then I'm gonna rename this just so I remember this is going to be compose index query so we queried by an index number now I'm going to add another compose and on this one I'm gonna drill into this so again I'm actually going to use the same expression that I used up here so I can actually copy it so I'm gonna copy this expression cuz I'm gonna use the same expression and I can't just paste it here remember you can't type expressions like this unless you're in advanced mode so you have to go to the expression and any copy and pasting you do in the Express area okay so now that I have it in there it's a bona fide expression if it's not colored color-coded it's not gonna work so if I paste this over here notice there's no colors up that's not gonna work okay and if you are working in advanced mode over here it'll start with an @ sign all right and that will give you a tip that it will work all right so now I'm going to specifically call for index number two I'm gonna call for the column issues to do all right just remind you look at the spreadsheet I'm looking at index number two and I'm asking for the value of issues to do okay all right I'm gonna click okay let's run a test on this up something I forgot to do it looks like I have what's wrong so I'm gonna do this a little bit different let's start over and let's just type first and let's go get our output so now oh we don't want the compose index output we want the list of items so let's do first two value here and so now I've got the right body in there and we'll do the two and we'll do the shoes to do let's just see if we're spelling that right issue to do not issues sure to do update did you somebody catch that before I bet you somebody did I but you're one of you out there we're like screaming and there's our second issue to do and it worked out just beautifully and that is your introduction to arrays even got to see me troubleshoot a mistake and this is just to get you started for your beginners learning what an array is in part 2 which will be next month I'm going to take this from an intermediate level and look at some of the things you can do with arrays
Info
Channel: Audrie Gordon
Views: 23,314
Rating: 4.9729729 out of 5
Keywords: Microsoft Flow, Microsoft, Arrays, Friday Functions, #FridayFunctions, Variables, Arrays in Flow, Excel, CreateArray(), First(), Last(), Getting an array by the index number, index, Getting started with Microsoft Flow Expressions, Advanced Expressions, Tips and Tricks, workflow, workflow expressions, what is an array?
Id: PRKcQ0Q4BJE
Channel Id: undefined
Length: 20min 11sec (1211 seconds)
Published: Fri May 10 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.