Beast Mode

Beast Mode

Count transactions AND sum quantity on specific transactions by type

I have a card that counts the transactions type by month. Some of the transactions have a quantity so I need to sum the quantity instead of just counting that transaction one time. I'm not quite sure how to go about that. I need to be able to say if it is this type of transaction then sum the quantity otherwise count the transaction. My attempts at a best mode have not worked out.

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In

Best Answer

  • Coach
    Answer ✓

    Are your transactions duplicated?

    If not you could do a conditional sum like:

    1. SUM(CASE WHEN `transaction_type` = 'Quantity' THEN `quantity` ELSE 1 END)
    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**

Answers

  • Coach
    Answer ✓

    Are your transactions duplicated?

    If not you could do a conditional sum like:

    1. SUM(CASE WHEN `transaction_type` = 'Quantity' THEN `quantity` ELSE 1 END)
    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Contributor

    Agree with @GrantSmith.

    Another calc that would count the transaction as 1 if there is no quantity would be sum(ifnull(`quantity`, 1)).

  • Thank you! This worked perfectly! I tend to overthink things.

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In