Git Product home page Git Product logo

googleapps_sumbycolor's Introduction

clupasq

Here are my dotfiles.

Installation

cd ~/.config
git clone https://github.com/clupasq/clupasq.git
cd clupasq
./setup.sh

googleapps_sumbycolor's People

Contributors

clupasq avatar elhoyos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

googleapps_sumbycolor's Issues

countWhereBackgroundColorIs ?

Is there a way to count background or foreground cells with your script?

Like a few others that created issues, i was under the impression that it would add the total of cells w/ the specified color given (without a number present or not).


I'm looking for something like this:

countWhereBackgroundColorIs(<color>, <range specification>, [<spreadsheet key>])
or
countWhereForegroundColorIs(<color>, <range specification>, [<spreadsheet key>])

Code is not pulling correct numbers on entry

After coming across your code on stackoverflow, it looks like this is exactly what I need. I was pretty excited to try it out as it would help me simplify my spreadsheet

So I set it up, used the "getBackgroundColor" function with "" around the cell number, and it pulls the color code (in this case #ff0000 or #b7b7b7). However, when I use the "sumWhereBackgroundColorIs("#ff0000","B3:B500", "", "B3:B500")" it responds with 0 cells holding that color, even though I have in B3 that is being used by getBackgroundColor to let me know at hex code to check for.

I really do think this would do exactly what I am hoping for. I tried using the Google Scripts debugger, but it isn't incredibly helpful in this situation (as it expects there to be a range of something, and there isn't one).

Add equivalent functionality for count

This script works great and it would be lovely if it provided count functionality as well.

In a case where I needed that, I added the following two functions:

function countWhereBackgroundColorIs(color, rangeSpecification, key) {
  var condition = function (cell) { return cell.getBackground().toLowerCase() == color.toLowerCase(); };
  return countByCondition(rangeSpecification, condition, key);
}

/**
 * Counts number of occurrences in the given range that have a
 * specific condition.
 *
 * @param {rangeSpecification} rangeSpecification - the range to search against.
 * @param {condition} condition - a function that determines if the cell should be
 *        counted or not.
 * @param {key} key (optional) - the key of a remote spreadsheet. If provided the
 *        range lookup will be done remotely.
 * @return A count of matching cells.
 * @customfunction
 */
function countByCondition(rangeSpecification, condition, key) {
  var sheet = _getSpreadsheet(key);
  var range = sheet.getRange(rangeSpecification);
  var count = 0;
  
  for (var i = 1; i <= range.getNumRows(); i++) {
    for (var j = 1; j <= range.getNumColumns(); j++) {
      var cell = range.getCell(i, j);
      if(condition(cell)) {
        count++;
      }
    }
  }
  
  return count;
}

To add it properly the following is needed:

  • Add other count variants
  • Remove code duplication
  • Update readme
  • Rename repository

shows 0 for all sums

I have been using these functions for quite some time. Today the functions are behaving inappropriately and shows 0 for all the sums even for my older sheets. Not sure if this is because of some updates from google sheets or what...

Auto-update not working

For some reason update trick is not working as desribed. Have there been any changes in the script?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.