Get Last 5 in Column, Then Add, Average & Display. Six Amazing Examples. Excel Magic Trick 1650.

Поділитися
Вставка
  • Опубліковано 15 вер 2024
  • Download Excel File: excelisfun.net...
    Learn how to get the last 5 numbers in a column and then add, average and display the last 5 items. Learn about a simple solution to this common task using the INDEX and ROWS functions and the Excel Table feature. See Six Examples. See the Excel Functions: INDEX, ROWS, SUM, AVERAGE, IF, FILTER and ROW.
    1. (00:01) Introduction.
    2. (00:24) Create Dynamic Range using INDEX and ROWS function with an Excel Table.
    3. (01:28) SUM to add the dynamic range.
    4. (01:44) AVERAGE to average the dynamic range.
    5. (01:57) Non-Office 365 solution to display last five values.
    6. (02:45) When you should NOT use IFERROR Function.
    7. (03:30) Office 365 New Calculation Engine solution to display last five values.
    8. (03:54) Formula for extracting last five text items.
    9. (04:13) FILTER Function solution (not the best option).
    10. (04:32) Summary and End Video Links.

КОМЕНТАРІ • 77

  • @excelisfun
    @excelisfun  4 роки тому +1

    Topics:
    1. (00:01) Introduction.
    2. (00:24) Create Dynamic Range using INDEX and ROWS function with an Excel Table.
    3. (01:28) SUM to add the dynamic range.
    4. (01:44) AVERAGE to average the dynamic range.
    5. (01:57) Non-Office 365 solution to display last five values.
    6. (02:45) When you should NOT use IFERROR Function.
    7. (03:30) Office 365 New Calculation Engine solution to display last five values.
    8. (03:54) Formula for extracting last five text items.
    9. (04:13) FILTER Function solution (not the best option).
    10. (04:32) Summary and End Video Links.

  • @dennisd5776
    @dennisd5776 4 роки тому +5

    Another clear and concise video. Thank you for showing those of us who don not have O360 how to accomplish the same task. Please continue to include us.

    • @excelisfun
      @excelisfun  4 роки тому +1

      I will : ) Office 365 IS the future, but the majority of Excel users are not there yet! I got your back : )

  • @Excelambda
    @Excelambda 4 роки тому +2

    Very nice Mike!!! Came out with this
    =INDEX(fSales[Numbers],SEQUENCE(D3,,COUNTA(fSales[Numbers])-D3+1))

    • @excelisfun
      @excelisfun  4 роки тому

      Very cool. I wonder if INDEX SEQUENCE or INDEX:INDEX is faster ?

    • @Excelambda
      @Excelambda 4 роки тому

      @@excelisfun If there is somebody to answer this question you are the one. :-))). I presume INDEX:INDEX. There is an add in for this calc, I do not have it. The LET functions should be timed also, using variables could have the benefits of helper columns.

  • @mattschoular8844
    @mattschoular8844 4 роки тому +3

    The new calculation engine along with Dynamic Arrays are so powerful. I foresee many more awesome videos to come. Thanks Mike for sharing your knowledge.

    • @excelisfun
      @excelisfun  4 роки тому

      Yes, I agree, all about 3000 videos will have to be re-done ; )

  • @davebowman5392
    @davebowman5392 4 роки тому

    Thanks Mike, getting 'last numbers', especially when it has to be dynamic, has always been a struggle for a lot of people, this explains it clearly.

    • @excelisfun
      @excelisfun  4 роки тому

      It is a very common task.ROWS and INDEX make it less of a struggle : )

  • @ashoksahu9546
    @ashoksahu9546 4 роки тому +1

    Waooo...... Excellent video.

    • @excelisfun
      @excelisfun  4 роки тому

      Glad you like it, Ashok!!!

  • @Excelambda
    @Excelambda 4 роки тому +3

    A longer formula but is one cell formula that puts on the first row the total
    =CHOOSE(INDEX(SEQUENCE(D3+1,,2,0)-MUNIT(D3+1),,1),"Tot last "&D3&" = "&SUM(INDEX(fSales[Numbers],SEQUENCE(D3,,COUNTA(fSales[Numbers])-D3+1))),INDEX(fSales[Numbers],SEQUENCE(D3+1,,COUNTA(fSales[Numbers])-D3)))
    Could be set also to put more data on the same array formula,like the average on second cell, or at the end, manipulating CHOOSE and MUNIT a lot can be done, for the benefit of only one cell. With LET could be much easier to understand and read. If is interest I can write it down. :-)

  • @robertovelicaz7719
    @robertovelicaz7719 4 роки тому

    Excellent Mike....I used your old formula when I was tracking the last five results of teams in a league. Thanks for the update!

    • @excelisfun
      @excelisfun  4 роки тому +1

      You are welcome, Roberto : )

  • @MalinaC
    @MalinaC 4 роки тому

    New dynamic formulas... :) I love them :)

  • @johnborg5419
    @johnborg5419 4 роки тому

    Thanks Mike, and thanks for contributing to the situation at the moment, with your videos. :) :)

    • @excelisfun
      @excelisfun  4 роки тому

      You are welcome, John Borg : )

  • @DougHExcel
    @DougHExcel 4 роки тому

    Dang..epic...thanks again. Then I saw Bill's LET example. Another cool variation. Wow...you guys rock

    • @excelisfun
      @excelisfun  4 роки тому

      Just use Szysz's formula without LET, and it is even better!!!!!

  • @pmsocho
    @pmsocho 4 роки тому

    Thanks for the video!

  • @sachinrv1
    @sachinrv1 4 роки тому

    That's amazing Mike. The beauty with Excel is that, there are so many different ways of doing the same thing. One can also use combination of SUM, OFFSET and COUNT, something like =SUM(OFFSET(B2,COUNT(B3:B22),,-D3,1)), same for average. For displaying last 5 I've this: =IF(ROWS($F$6:F6)>$D$3,"",INDEX(B3:B22,COUNT($B$2:B22)-$D$3+1)). Table mouse handle is not working, hence given the range. Thanks & Cheers :)

    • @excelisfun
      @excelisfun  4 роки тому +1

      Thanks for your formula contributions, Sachin!!!!!

  • @chrism9037
    @chrism9037 4 роки тому

    That was very impressive Mike, thank you!

    • @excelisfun
      @excelisfun  4 роки тому

      You are welcome, Chris : ) : )

  • @FaysalEasyExcel
    @FaysalEasyExcel 4 роки тому

    Thanks a lot

  • @simfinso858
    @simfinso858 4 роки тому

    Boom Boom Index Formula.Amazing

  • @Reduce_Scan
    @Reduce_Scan 4 роки тому

    Thank you Mike
    I try to solve
    =IFERROR(INDEX($B$3:$B$23;COUNTA($B$3:$B$23)-$D$3+ROWS($D$3:D3));"")
    =SUM(INDEX(B3:B23;COUNT(B3:B23)-D3+1):INDEX(B3:B23;COUNT(B3:B23)))
    =AVERAGE(INDEX(B3:B23;COUNT(B3:B23)-D3+1):INDEX(B3:B23;COUNT(B3:B23)))

    • @Reduce_Scan
      @Reduce_Scan 4 роки тому

      =INDIRECT(ADDRESS(ROWS($B$3:$B$23)-$D$3+ROWS($B$1:B3);2))
      =SUM(INDIRECT(ADDRESS(ROWS($B$3:$B$23)-$D$3+ROWS($B$1:B3);2)):INDIRECT(ADDRESS(ROWS($B$3:$B$23)+ROWS($B$1:B3);2)))
      =AVERAGE(INDIRECT(ADDRESS(ROWS($B$3:$B$23)-$D$3+ROWS($B$1:B3);2)):INDIRECT(ADDRESS(ROWS($B$3:$B$23)+ROWS($B$1:B3);2)))

    • @Reduce_Scan
      @Reduce_Scan 4 роки тому

      =IF(ROWS($A$1:A1)>$D$3;"";OFFSET($B$3;ROWS($B$3:$B$23)-$D$3+ROWS($A$1:A1)-1;;$D$3))
      =SUM(OFFSET(B3;ROWS(B3:B23)-D3;;D3))
      =AVERAGE(OFFSET(B3;ROWS(B3:B23)-D3;;D3))

    • @excelisfun
      @excelisfun  4 роки тому +1

      Lots of great formulas, except for IFERROR : (

  • @edge5817
    @edge5817 4 роки тому +1

    Amazing Mike!

  • @ismailismaili0071
    @ismailismaili0071 4 роки тому

    I need to buy office 365 really cause these stuff are fun

  • @Luciano_mp
    @Luciano_mp 4 роки тому

    Nice.👍👍👍

  • @prameeSri143
    @prameeSri143 4 роки тому

    You are really awesome Mike.. nothing more to say..:-)

  • @bevonclarke
    @bevonclarke 4 роки тому

    Fantastic!

    • @excelisfun
      @excelisfun  4 роки тому +1

      Glad you like it, bevon!

  • @JLyck
    @JLyck 4 роки тому

    Your videos are almost mesmerizing!

    • @excelisfun
      @excelisfun  4 роки тому +1

      That should be a good thing. I Think?

    • @JLyck
      @JLyck 4 роки тому

      ExcelIsFun I think it is! 🙂

  • @dh6167
    @dh6167 4 роки тому

    You're a boss! Thank you so much

    • @excelisfun
      @excelisfun  4 роки тому

      You are welcome so much, D H : ) : ) Thanks for the question!!!

  • @stevennye5075
    @stevennye5075 3 роки тому

    Nice work!

  • @BillSzysz1
    @BillSzysz1 4 роки тому

    Thanks Mike :-))
    From me, LET of course (my new favorite function)
    =LET(rng,fSalesAnswer[Numbers],INDEX(rng,SEQUENCE(D3,,ROWS(rng)-D3+1)))

    • @excelisfun
      @excelisfun  4 роки тому

      Yes, LET is delightful! Thanks for the elegant solution, O Poet of Excel and PQ : )

    • @excelisfun
      @excelisfun  4 роки тому +1

      BTW, Masterful One, your formula is even better without the LET : ) : ) : ) : )

  • @ndjanardhan
    @ndjanardhan 4 роки тому

    Thank You Sir for the Great Video , We Can Use Latest Function i.e. Let Expression in Office insider

    • @excelisfun
      @excelisfun  4 роки тому +1

      You are welcome, Janardhan!!! LET... soon : )

  • @big1975E
    @big1975E 4 роки тому +2

    Is there a reason why you used INDEX’s instead of OFFSET? Is there an advantage to using one over the other?

    • @excelisfun
      @excelisfun  4 роки тому +4

      Yes, big1975E, OFFSET is a volatile function, which means it has to recalculate the result any time you do anything, hit enter, insert a column and so on. This does not matter if the model is small. But often, people build models that have many formulas and span many sheets, then functions like OFFSET can really slow things down. That is why I try to teach methods that will be more efficient.

    • @big1975E
      @big1975E 4 роки тому

      That makes sense. Thank you! I would love to see your solution for a complex TEXTJOIN formula that creates a list in a single cell of totals for the last three years where the year and total are separated by a hyphen and each year is on a separate line in the cell. I have a formula but it calculates really slowly.

  • @powerthinking1
    @powerthinking1 11 місяців тому

    Hello, In this video you use a Named Range called fSalesAnswer that auto increments whenever a row is added. Do you sell a document that I can learn how to create that function or Macro? Thanks!

  • @HusseinKorish
    @HusseinKorish 4 роки тому

    This is Amazing

  • @kirup69
    @kirup69 4 роки тому

    Amazing

    • @excelisfun
      @excelisfun  4 роки тому +1

      Glad it is amazing for you, Kiruna!!!

  • @mihirpatel294
    @mihirpatel294 2 місяці тому

    How do you do for rows ?

  • @goergejohn6986
    @goergejohn6986 3 роки тому

    What to do to get the last five based on a criteria from another column (variable)?

  • @surajpatil146
    @surajpatil146 3 роки тому

    how can i use this for last 5 in rows, please reply

  • @vinto1583
    @vinto1583 3 роки тому

    How do i represent the result from the formulas horizontally in a row ..... not vertically in a column like in the above example ,say last 5 results for a team in a tabular format where the results are tabulated in a vertical format , whereas in the output id like it to be represented horizontally

  • @clairezhang7351
    @clairezhang7351 4 роки тому

    Thank you Mike for sharing. Does the index(rows()) formula work for pivot table as well? It does not seem to be dynamic as I have to manually select the rows every time the row number changes.

    • @excelisfun
      @excelisfun  4 роки тому

      I have not tried that. It sounds like from your test, it does not work.

    • @clairezhang7351
      @clairezhang7351 4 роки тому

      @@excelisfunOk. Thank you Mike.

  • @Excelambda
    @Excelambda 4 роки тому

    This is one cell array formula that sets above the last rows extracted, the SUM and the AVERAGE. The formula is:
    =LET(
    lst,D3,slnr,fSales[Numbers],
    trw,COUNTA(slnr),
    inrw,SEQUENCE(lst,,trw-lst+1),
    in,INDEX(slnr,inrw),
    ch,SEQUENCE(D3+2,,3,0)-INDEX(MUNIT(D3+2)*2,,1)-INDEX(MUNIT(D3+2),,2),
    arry,CHOOSE(ch,"Tot lst "&lst&" = "&ROUND(SUM(in),2),"Avrg lst "&lst&" = "&ROUND(AVERAGE(in),2),INDEX(slnr,SEQUENCE(lst+2,,trw-lst-1))),
    arry
    )
    The variables we use are :
    lst as value in cell D3,slnr as the sales number table itself,
    trw as total rows of the table (no blanks or text scenario, could be modified to cover the extraction if there are blanks or text),
    inrw as the array of the last rows used in INDEX extraction,
    in as the INDEX itself extracted,
    ch as the array that we need for the CHOOSE index argument, creates an array like this {1;2;3;3;...} that should be dynamic to have as many "3" as we have last rows,
    arry as our result array, the CHOOSE itself with value 1 argument as the SUM, value 2 as AVERAGE, and the bunch of values 3 as the INDEX.
    Note: for this to work, INDEX used inside CHOOSE is 2 rows taller.
    I can not imagine the size of this formula without LET. The benefit is HUGE. For anybody to use it, you only need the table created, input the cell reference for the last rows, input the table name, copy, paste, and you are good to go. Everything else is contained in the formula.

    • @excelisfun
      @excelisfun  4 роки тому

      LET is very amazing, as is your formula cr gr0912!!!!!

  • @planxlsm
    @planxlsm 4 роки тому

    2:34 Condition If

    • @excelisfun
      @excelisfun  4 роки тому

      Yes, we do not want IFERROR ; )

    • @planxlsm
      @planxlsm 4 роки тому

      @@excelisfun Yes !

  • @mohamedchakroun4973
    @mohamedchakroun4973 4 роки тому

    Niceeeee

  • @lampros6156
    @lampros6156 4 роки тому

    We might also use =IF(ROWS($G$6:G6)

  • @snowman200710
    @snowman200710 Рік тому

    Hopefully you see this…. When I put this in I keep getting zero HELP