Forum Discussion
Tal Feinberg
Jan 17, 2018Copper Contributor
total a column in OMS
Hello,
How can I sum a column?
I have each row dcount with number of customers and I would like to know what is the total of customers.
I want to present a new row with the total number of ...
Noa Kuperberg
Microsoft
Jan 17, 2018Hi Tal,
To only get the sum of the dcount value, you can do something like the bottom line here:
Update | summarize dcount(Product) by Computer | summarize sum_dcount=sum(dcount_Product)
To add the summed value to each row, you can do this:
let summed_dcount_products_by_computer= Update | summarize dcount(Product) by Computer | summarize sum_dcount=sum(dcount_Product); Update | extend summed_dcount=toscalar(summed_dcount_products_by_computer)
HTH,
Noa
Tal Feinberg
Jan 17, 2018Copper Contributor
Hi Noa,
Thanks, but when I do this
| summarize dcount(Product) by Computer | summarize sum_dcount=sum(dcount_Product)
Its the only thing that displayed.
I want to continue and display all the results + the total in the same table/view.
- Ketan GhelaniJan 21, 2018Former Employee
Just keep in mind, that you cannot really sum a dcount, unless you know that each row is actually is mutually exclusive. If you can expand on your scenario there could be other options (for e.g. you may have to use dcount_hll and hll_merge )
- Noa KuperbergJan 18, 2018
Microsoft
ok, that second option I added is for that use case.