Sum True

This sounds so dumb and simple. But I'd give my left leg to be able to sum a true/false column and have it give me a sum of True (basically treating it like a 1 and 0) without having to do a beastmode calculation.

1
1 votes

Comments

  • Can't you just do the following?

    SUM(`your_boolean_column`)

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • LeeJo
    LeeJo Member

    That was what I thought but I've had no luck. My SQL query brings it in as a string, is there anything in particular to turn it into a boolean, keeping true/false as the content (for user filters)? Right now I toss in a calculation that says true = 1 and false = 0, but that leads ultimately having two columns for me to manage insights into a single column. Below is a screenshot of the original sql output.

    image.png
  • Boolean sum depends upon whether you mean Boolean Summation as a logical "or". Using a formula like the following would give you the logic that if any one of the values is true the result is true.

    MAX(CASE WHEN `boolean_number` THEN 1 ELSE 0 END)
    

    Domo is not going to be able to do the summation on a string value. Try casting it to a Boolean true/false or 1/0. If you are working with string values and you want to return a one if any row contains true the something like

    MAX(CASE WHEN LOWER(`your_column`) = 'true' THEN 1 ELSE 0 END)

    might work for you. But alas…this is a Beast mode calculation which you hope to avoid.

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **