Ability to SUM multiple columns
See original GitHub issueIs your feature request related to a problem? Please describe.
I’d like to be able to use the Sum
function over multiple columns.
Example for a model
class Stats(Model):
one_column = fields.IntField(default=0)
two_column = fields.IntField(default=0)
I’d like to be able to do run a query like select sum(one_column+two_column) from stats
Describe the solution you’d like
Stats.annotate(total_sum=Sum('one_column+two_column'))
(or something similar)
Additional context
Pypika can already resolve this as seen in this test:
fn.Sum(self.table_abc.fizz + self.table_abc.buzz)
Issue Analytics
- State:
- Created 4 years ago
- Comments:18 (8 by maintainers)
Top Results From Across the Web
sum multiple columns, how to? - Microsoft Power BI Community
Solved: Hi, Im new in powerBi and Im working in some datat wherein I need to calculate per row with multiple colums. at...
Read more >Power BI Sum Multiple columns [With 21 Useful Examples]
To Sum Multiple columns in Power BI, we use the SUM() or SUMX() function in Power BI,. The Power BI Sum() function will...
Read more >SUMIF multiple columns with one or several criteria in Excel
This tutorial will teach you a few easy ways to sum multiple columns in Excel based on a single or multiple criteria.
Read more >How To Sum Columns in Excel Using Multiple Methods ...
In the "Totals" row of the table, select the cell under the column you want to sum, then use the small down arrow...
Read more >Add Multiple Columns Using DAX In Power BI
There are two ways to achieve the same sum operation on multiple columns. Use DAX expression in a Calculated column; Use DAX expression...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@grigi Thank you so much for your discussion. I will make PR with 1 (but i’m not sure that i’m doing good. i will make WIP PR soon. Review that PR plz!) As you said, we need to think more carefully about 2 and 4.
Yes,
source_param
is a prime example where we want a Model to be different compared to a legacy DB column name.We should definitly allow
F
expressions in annotations. And the inverse, of annotations in.update(...)
operations as well. Maybe we can get away by just makingFunction
aware ofF
expressions?