we have a column with product names and we need a running count one two three and we need to do it with power query now last video Excel magic took 1588 we use table dot rows count inside of table dot add columns and built to custom functions well this formula is very calculation intensive as the formula copies down the column luckily bill sizes in Veda commented at YouTube about how to do this with grouping and an index column with a single cell in our table selected we come up to data getting transformed from table this brings our table into the power query window I want to rename this something like transaction product running count step one we come over to product right click down to group by our goal is to group all of the products quad quad together and then all the car Lotus together so we select product the new column name something like table with index I don't really care what this operation is for the time being click OK up in the formula bar I'm gonna expand table dot group is the function that's the previous step the column that determined the unique list of items that we group by is product in double curly brackets that's a list within a list that's our single calculation now everything after each I'm gonna highlight and use the Delete key to each keyword allows us to make a calculation for each row for each row we're gonna use table dot add index column open parentheses now it requires a table and when we use the each shorthand for a custom function the way we access all of the records for a particular condition is with underscore that is our table comma the new column name in double quotes running Cal comma the initial value we're going to start at one comma and we're gonna increment by one this will give us one two three four and so on for each group set of records now we have list within a list syntax oh we typed curly bracket curly bracket and then close parentheses to close off table dot group when I hit enter we get just what we want there's our running count for the quad running count for Carlota now I'm going to show you two ways to do this we'll use the user interface and then we'll do a quick step using just the f of X now with this running count we can expand click the expand button uncheck we want running count and transaction number click OK now I want to reorder the column so I'm going to drag transaction number to the left of product now all the quads are together but I really want it sorted by transaction number so I select the drop-down a to Z now I can add some data types something like whole number whole number and there we have the original order and our running count now there's a faster way we can do this if we come to expand table with index right click delete to end delete notice we have a column of tables and what we really want to do is combine them a Penda manaan top of the other well notice this is the name of the step and if I want to extract a single column I can use a field access operator so I come up to f of X and click that's the full table from the previous step repeated but if I want just this column I use my field access operator square brackets and then the name of the column table with index and enter so in one step I have extracted just the tables now I can use table dot combined open parentheses close parentheses and when I hit enter I've taken that column of tables and combined them the last step we need to do is I don't want the quads all together I want sorted by transaction number so click the drop down select a to Z and there's our running count without having to use a calculation intensive formula for each row now I can close and load close and load to existing sheet something like j4 click OK man it's awesome hanging out on our online Excel team they - bill scissors and vada we'll see you next trick
transcript
excelisfun - Power Query Running Count with Grouping & Add Index - Excel Magic Trick 1589

Community upload. AI output has not been independently verified.