JavaScript Filter Method Tutorial - Google Sheets Apps Scripts - Array Methods Part 7

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 พ.ย. 2024

ความคิดเห็น • 81

  • @eyemoksha
    @eyemoksha 2 ปีที่แล้ว +1

    You are a Perfect Teacher. You have taught me a lot. THANK YOU for all your lessons.

  • @jmcanally3
    @jmcanally3 5 ปีที่แล้ว +3

    Thank you. This technique just saved me hours, days, months of frustration. Love the videos.

  • @rashidanwar7831
    @rashidanwar7831 5 ปีที่แล้ว +2

    You are really doing a great job. Thumbs up for your efforts and easy to understand teaching style. Thanks a lot.

  • @Ro0Dr1Gg0
    @Ro0Dr1Gg0 4 ปีที่แล้ว +2

    Amazing!!! Thanks for share!!

  • @plinioglad
    @plinioglad ปีที่แล้ว

    Very good!!!!! Congratulations!!!

  • @jarabialex
    @jarabialex 3 ปีที่แล้ว +2

    Awesome! Awesome! Awesome!

  • @Barrel4336
    @Barrel4336 4 ปีที่แล้ว +1

    This was good overview on filters for Apps Script, following your methods I was able to get a filter function to work, but I was not able to get the function to filter based on a specific date.
    This returns me an empty array and I was wondering if you had any advice for using the filter function for a dataset that has dates associated with it?

  • @bruno_snitram
    @bruno_snitram 2 ปีที่แล้ว

    Awesome. Thank you for sharing.

  • @kafkareader3212
    @kafkareader3212 5 ปีที่แล้ว +2

    Thanx a lot, man. You give a lot of good information to up GS skills. I am from Russia and here i cant find a lot of answeres for my questions. You help a lot. Keep going and good luck. :)

  • @siocgsd7894
    @siocgsd7894 2 ปีที่แล้ว

    Hello. I would like to know if this is, like, automated? Like when you add data it will be added on the filtered data on the tab that your appscript created. Or do you need to click run again?

  • @TinaFO-tc2dd
    @TinaFO-tc2dd 4 หลายเดือนก่อน

    Thank you for this video! I would like to know if there is a way of filtering by "value" and "background color". Thank you again!

  • @yrin84
    @yrin84 4 ปีที่แล้ว

    your videos are the best on this field!

  • @daytodatainc.2520
    @daytodatainc.2520 3 ปีที่แล้ว

    Great video, simplistic examples so it all makes sense!

  • @joycekosak
    @joycekosak 3 ปีที่แล้ว +1

    This is awesome, gave me exactly what I needed to know to get the data filtered. I also want to update the column next to my original data indicated that I have copied those rows that met the filter conditions. Any thoughts on how to do that? I filter and copy the data to another sheet, and I want the original sheet to now indicate "Submitted" to the lines that were copied over.

  • @lowernorth9972
    @lowernorth9972 5 ปีที่แล้ว +1

    This would be great if it returned filtered items from a data validation drop down within the spreadsheet. Dig the videos, keep it up. Love the typos too XD

  • @danieldotimas1786
    @danieldotimas1786 3 ปีที่แล้ว +1

    Thank you for this. May I ask how to Reset all existing filters in a sheet using script?

  • @lauramcooley
    @lauramcooley 2 ปีที่แล้ว

    I feel like a fog has been lifted. Thank you!!

  • @carmencastro5512
    @carmencastro5512 6 ปีที่แล้ว

    Here I found what I was looking for, thank you so much for sharing ......

  • @MuriloMBarquette
    @MuriloMBarquette ปีที่แล้ว

    Fantastic!

  • @profleomartinez1551
    @profleomartinez1551 3 ปีที่แล้ว

    Hi, excellent!
    I implement it in reading my students' spreadsheet. I separate one class from another and define it in a cell.
    Thank you!!

  • @edwinalansilvatorres544
    @edwinalansilvatorres544 2 ปีที่แล้ว

    Awesome 😃 Thanks!

  • @mikemccartneyable
    @mikemccartneyable 6 ปีที่แล้ว

    Absolutely super channel and content.

  • @michaeltimpano1278
    @michaeltimpano1278 4 ปีที่แล้ว

    Great videos! Very helpful. How would you use filter or map to search the first row columns headings for a key word and then return all the rows that are in that column? I can pull all the rows with a filtered word, but not if the search is restricted to the first row. Any ideas? Thanks.

  • @home2office515
    @home2office515 3 ปีที่แล้ว

    Nice video

  • @tonypeterson3477
    @tonypeterson3477 5 ปีที่แล้ว

    Thanks for this filter video guide. It is very useful. May I please know the scripts for the sale rep who are not "Jerry Jefferson"? I would greatly appreciate it if you could help me with this matter.
    Tony

  • @garychadwick1240
    @garychadwick1240 4 ปีที่แล้ว +1

    Once again, thanks for another excellent tutorial. One question though. I’ve noticed that sometimes you use == and sometimes === in your formula. What’s the difference?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  4 ปีที่แล้ว +2

      On a basic level:
      == checks for value only
      === checks for value and type
      example:
      4 === "4" IS NOT TRUE, because one is a number, the other is text. So the type is not the same.
      4 == "4" IS TRUE, because == doesn't check the type.

    • @garychadwick1240
      @garychadwick1240 4 ปีที่แล้ว

      Learn Google Spreadsheets Makes perfect sense. Thanks for your fast response! 👌🏻

  • @dme3327
    @dme3327 3 ปีที่แล้ว

    HI, Could you please let me know how can i copy data with hyperlink format suppose i have data in which some cells have hyperlink and if copy data and paste it another sheet then hyperlink format should be same, is there any way to do this activity please do let me know

  • @TheOrteme
    @TheOrteme 3 ปีที่แล้ว

    MAN YOU DOING GREAT THING THANK YOU!

  • @luisgermanorregocampano1987
    @luisgermanorregocampano1987 2 ปีที่แล้ว

    Impressive! Thank you very much for this tutorial. Do you still have your patreon?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  2 ปีที่แล้ว

      Thank You! Yes www.patreon.com/chicagocomputerclasses

  • @adolfoenriquelobos8117
    @adolfoenriquelobos8117 4 ปีที่แล้ว

    Excellent video!! It helps me to solve searches efficiently.
    My query is the following, How can I get the row in which the entered value was found? Thank you!

  • @jasonmagee5988
    @jasonmagee5988 3 ปีที่แล้ว

    Is there a way to place the results on an html form similar to your instructions for the search in a crud?

  • @ConsulthinkProgrammer
    @ConsulthinkProgrammer 3 ปีที่แล้ว

    Sir, suppose I have script like this:
    var leaveFilter = data.filter(data => {return data[1 == "Annual Leave" || data[1] == "Vacation leave" || data[1] == "Sick" || data[1] == "Important leave"});
    How if I want make some iteration, or loop perhaps, so I just have to make that filter in array like this:
    filters = [ "Annual Leave", "Vacation leave", "Sick", "Important leave"]
    Which later I want that I could use that filters variable to do some iteration/loop in filter method above. Could you help to break this problem?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 ปีที่แล้ว +1

      var leaveFilter = data.filter(data => {return [ "Annual Leave", "Vacation leave", "Sick", "Important leave"].includes(data[1])});

    • @ConsulthinkProgrammer
      @ConsulthinkProgrammer 3 ปีที่แล้ว

      @@ExcelGoogleSheets Thanks a lot Sir. Perfectly works :D

  • @iArthurTou
    @iArthurTou 5 ปีที่แล้ว

    Can this filter method can filter date between or filter date by criteria bigger than day , less than date ? How can do it . Thanks !

  • @leorraedvalmonte
    @leorraedvalmonte 3 ปีที่แล้ว

    How do use multiple criteria but for each criterion that is blank have it disregard the data and filter only based on criteria that is non blank?

  • @giorgionatale7190
    @giorgionatale7190 3 ปีที่แล้ว

    Nice video man, but just a question .
    How can you filter de color of
    The cell?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 ปีที่แล้ว

      is you use getRange().getBackgrounds() instead of getRange().getValues() it will give you an array of colors in hex format.

    • @irfankalkar8461
      @irfankalkar8461 ปีที่แล้ว

      ​@@ExcelGoogleSheets I have already tried it, but this time we can't get the values of relevant rows as one column or as all columns which were filtered by color. Because, (firstly thanks for your video but) your video doesn't explain how to get Values of a row together with all columns if that row has relevant color which was expected to be found by filter.
      Also i want to make this filter as normal filter in same sheet by hiding the rows in which relevant value or background color are not found after filter query.
      Can you help me on this topic ?

  • @KhalilYasser
    @KhalilYasser 6 ปีที่แล้ว +1

    Thank you very much. As for the link of the sheet, when trying to navigate to script editor, it doesn't appear. Can you share the code?

    • @KhalilYasser
      @KhalilYasser 6 ปีที่แล้ว

      Here's the code used the video. Hope this helps others
      pastebin.com/k9sC42Lq

  • @arielzabatecuizon5147
    @arielzabatecuizon5147 3 ปีที่แล้ว

    Hi, how can I filter using partial string?, like I want to return all contains "tex".

  • @ruchikabadesra5888
    @ruchikabadesra5888 3 ปีที่แล้ว

    Hi. I used the same method to filter data and the same method to create a new sheet and paste data using setvalues(). But it is throwing an error - TypeError: Cannot read property 'length' of undefined. I checked that the filtered data is not empty. On logging out the length, it is giving numeric values. Can you please help?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 ปีที่แล้ว +1

      Check your spelling, everything is case sensitive.

  • @syscomseatings8964
    @syscomseatings8964 4 ปีที่แล้ว

    This is great tutorial .. IS there a way where we can have one single function which will take multiple search as array and corresponding columns in which to search as an other array and search ie i want to search for "yes" in col3 , completed in col4 , >50 in col5 , I might not have all these 3 everytime... so how do i have a generic function which will run as per length of the search item/column arrays. Hope I am making sense :(

  • @pichit.raetai
    @pichit.raetai 5 ปีที่แล้ว

    Wow.. thank you very much

  • @ajayshakti5818
    @ajayshakti5818 4 ปีที่แล้ว +1

    Thanks ..

  • @andreaguerri.educational
    @andreaguerri.educational 3 ปีที่แล้ว

    Hi, thanks...but I have a problem with between date array. For example: in my spreadsheets I have a colum with date, it's work currently with getMonth, getFullYear, but not working with between date. This is a code:
    var sheet = SpreadsheetApp.getActive();
    var ss = sheet.getSheetByName("Fatturato");
    var data = ss.getRange(4, 4, ss.getLastRow(), 4).getValues();
    var startDate = new Date("2017-01-01");
    var endDate = new Date("2022-01-01");
    var result = data.filter(function(row){
    var d = new Date( row[0] );
    return d.setDate() >= startDate && d.getDate

  • @tomas_thephotographer
    @tomas_thephotographer 4 ปีที่แล้ว

    @Learn Google Spreadsheets, if I would like to at the end show in new sheet only 1 column and 7 column, how can I do it?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  4 ปีที่แล้ว

      Use .map method th-cam.com/video/WA8QotNEVc4/w-d-xo.html

  • @ChallaRamakrishnaDynamicsAX
    @ChallaRamakrishnaDynamicsAX 5 ปีที่แล้ว

    Just amazing!!

  • @128MrAndy
    @128MrAndy 2 ปีที่แล้ว

    Thanks!

  • @phoenixempire8886
    @phoenixempire8886 4 ปีที่แล้ว +1

    🙏🏻

  • @jihenothmen3275
    @jihenothmen3275 3 ปีที่แล้ว

    Hi
    thanks for this tutorial,
    when i insert a sheet i get an error message "ReferenceError: tab is not defined"

  • @ConsulthinkProgrammer
    @ConsulthinkProgrammer 3 ปีที่แล้ว

    How if we want to filter by date which is first column in the video, Sir? I've tried something like this:
    var date1 = new Date("2/15/2017");
    var dateFilter = values.filter(function(r) { return r[0] == date1; });
    But it didn't work and I just got an empty []
    How we could do that correctly Sir?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 ปีที่แล้ว +1

      var dateFilter = values.filter(function(r) { return r[0].getTime() == date1.getTime(); });

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 ปีที่แล้ว +1

      Be careful with time zones when you do this.

    • @ConsulthinkProgrammer
      @ConsulthinkProgrammer 3 ปีที่แล้ว

      @@ExcelGoogleSheets Thanks for your feedback and code Sir. I did a little bit of modification, then changed my time zone setting, considering your advice.. And, great, it works. Again, thanks a lot Sir :)

  • @paulloup5210
    @paulloup5210 6 ปีที่แล้ว

    Thank you very much !!!

  • @thiagodecastroartiga8893
    @thiagodecastroartiga8893 3 ปีที่แล้ว

    Man thanks again!!

  • @ravisingh2234
    @ravisingh2234 4 ปีที่แล้ว

    it's showing error like : TypeError: Cannot read property 'length' of undefined (line 12, file "Test")

  • @shaitaan0666
    @shaitaan0666 ปีที่แล้ว

    how to filter between two dates match with it data

  • @EnnaNadanthaalum
    @EnnaNadanthaalum 2 ปีที่แล้ว

    TypeError: Cannot read property '1' of undefined
    pls help

  • @NishantKumar-tc5ej
    @NishantKumar-tc5ej 2 ปีที่แล้ว

    This method is removing the header. It is possible to retain it?

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  2 ปีที่แล้ว

      let headers = data.shift()
      data = data.filter(logic)
      data.unshift(headers)

  • @jdee603
    @jdee603 3 ปีที่แล้ว

    I followed the advice in the video but I keep getting an error message
    TypeError: originalData.filter is not a function (line 8, file "Code")
    function myFunction() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var trn = ss.getSheetByName("Transactions");
    var originalData = trn.getRange(2, 1, trn.getLastRow()-1,7).getValues;
    var salesRep = "Jerry Jefferson";
    var data = originalData.filter(function(item){ return item[1] === salesRep && item[4] > 300; });
    var targetSheet = ss.insertSheet(salesRep);
    targetSheet.getRange(2, 1, data.length, data[0].length).setValues(data);
    }
    Any help?

  • @66Komodo
    @66Komodo 5 ปีที่แล้ว

    👍🏻

  • @dustinelliott-br2l359
    @dustinelliott-br2l359 5 ปีที่แล้ว

    Thank you. This is almost exactly what I am looking for, but I do not understand why I am receiving this error - TypeError: Cannot find function filter in object [object Array].- on this line: var data = originalData.filter(function(item){ return item[1] === salesRep && item[4] > 300; });

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  5 ปีที่แล้ว

      your error happens before that line.

    • @dustinelliott-br2l359
      @dustinelliott-br2l359 5 ปีที่แล้ว

      I tried again and it worked. I do not know why it did not work the first time. Thanks again. Very helpful videos.

    • @dustinelliott-br2l359
      @dustinelliott-br2l359 5 ปีที่แล้ว

      @@ExcelGoogleSheets If I had a dozen sales amounts that I wanted to filter on, and those amounts were in Col J of Transactions (rows 2-13), instead of writing several ||/or statements, is there a way I could incorporate indexOf into the filter function? That way, if the amounts in Col J changed, I would not need to modify the script. I saw something about indexOf > -1 online, but I cannot apply it correctly to this example. Thank you.

  • @sushilkumarthakur6033
    @sushilkumarthakur6033 3 ปีที่แล้ว

    #Deliting row based on condition or when the condition met and copying deleted row in another sheet.
    &How to get a particular array when the condition met (filter method doesn't go well as it returns a whole array of rows)
    Can anyone help me out with any inputs and video links? It will be appreciated.

  • @ลิขิตชัยกิจ
    @ลิขิตชัยกิจ 3 ปีที่แล้ว

    It shown TypeError: originalData.filter is not a function (line 7, file "filter") /which is var data = originalData.filter(function(item){ return item[1] === "BA"; });

    • @ExcelGoogleSheets
      @ExcelGoogleSheets  3 ปีที่แล้ว

      That means check the line
      var originalData = blah blah;

  • @bdawg7132
    @bdawg7132 5 ปีที่แล้ว

    Wish it worked for me.