# Count transactions AND sum quantity on specific transactions by type

Options
Member

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.

• Coach
Options

If not you could do a conditional sum like:

```SUM(CASE WHEN `transaction_type` = 'Quantity' THEN `quantity` ELSE 1 END)
```

**Did this solve your problem? Accept it as a solution!**

• Coach
Options

If not you could do a conditional sum like:

```SUM(CASE WHEN `transaction_type` = 'Quantity' THEN `quantity` ELSE 1 END)
```

**Did this solve your problem? Accept it as a solution!**
• Contributor
Options

Agree with @GrantSmith.

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

• Member
Options

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