How to add up non empty cells in a column after all search criteria

How to add up non empty cells in a column after all search criteria

TommTFGTommTFG Posts: 3Questions: 2Answers: 0

Hello, Looking for help. New to all this.

I am using Google Sheets database through Google Apps Script to generate website to use to out put our database and the ability to Filter it. I have successfully made this work with DataTables through google web Apps Script.

I have set it up to be able to filter to select a specific Agent using "Individual column searching (select inputs)" and also further filter via a range selecting specific Date Time Frame by adding in the "DataTables date range filter"

What I need to do now is once The search Filters are all selected and the results are shown. I want to be able to create stats on that agent. that show up on the Header or some other place holder on the website.

I have a number of columns that have dates in them. "Sent", "Met", "Offer", "Sold". The Sent date is the date I am using to Filter via the Date Range Filter. What I need is to Count the number of Cells in each of these Columns that have dates entered only. After which I need to run these numbers to produced % for a KPI. For Example Sent/Met % or a Sent/Sold %

My question is what would be the code and where to add it, to result in an output to the HTML to display these numbers and percentages calculations I need?. Also the code I need to add (and where) to the JavaScript or Code.gs to I capture the count of the non-empty cells for each column to out put to the HTML display needed mentioned above.

This is the last piece to the puzzle. I seems simple enough , but I have no idea how to implement or create the code needed. my searching has left me more confused.

Any Help would be great.

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    The specific code you need is hard to provide without seeing exactly what data you have. I have some suggestions you can look at but if you need more specific help I suggest building a simple test case with an example of your data.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    What I need is to Count the number of Cells in each of these Columns that have dates entered only.

    One option is to use the filter() API with the count() API to provide a count of the result from filter(). Use a conditional to check for the date or non-empty cell or whatever your specific criteria is for each column. Use the { search: "applied" } selector-modifier of the column() API to apply the filter() API to only those rows displayed based on your search criteria. A similar example can be seen here.

    out put to the HTML display needed mentioned above.

    You could use the search event to count the results of the filter() API and use jQuery or Javascript methods to populate the HTML elements with the calculations. The search event will keep the HTML output updated as the table is searched.

    Here is a very simple example that will display the number of London rows as the search takes place:
    https://live.datatables.net/joxoledo/1/edit

    Kevin

Sign In or Register to comment.