Macro for sum filtered

Hi i would love have yours help because i am creating a macro for sum some value.
In my case i am adding to every cell works that i need to pay, and i put date and value 1 in “J” cell for have value.

So =sum(j2:j28) i ll have the sum and till here is all ok.
If i use filter by date i ma seeing only the day selected but clearly office is continuing to sum J2 to J 28. How i could sum only the filtered one?

See function SUBTOTAL which ignores filtered rows and other subtotal formulas.
See also https://ask.libreoffice.org/uploads/short-url/m4CfCqn8ejQTSnyjsRjrJ48LYir.ods for a broader approach with no formulas at all.

1 Like

hi there, i was checking and pivot seems the solution.
I cannot do subtotal because i would like to have dynamic system for add value of works.
Could i ask advice for get value from sheets, if its possible? thanks in advantage

@marteIV, not knowing your level of familiarity with Calc, I might suggest that if you are only wanting to sum for a single, filtered date, then you could always just include another cell with the SUMIF() function. Pivot tables would be worth learning, but the approach below is workable although inferior.

To use this, see the attached ODS. Enter the date you want to filter for into the green cell before you filter on that date. If the green cell disappears, just filter for All dates again and it should reappear.

AlternativeToPivot.ods (13.8 KB)

I basically solved my problem melting all the solution :slight_smile:
So i did a table with sum in cells and close to it i used subtotal and i ll have solution filtered.

Anyway i would love know more about pivot and i was searching tutorial. Unfortunately there aren’t related to add more sheets on same pivot table. So how i could pick data from other table/sheets? thanks a lot

The posting I have deleted was written for another topic on a different forum. I use to write stuff in a text editor and paste the result into the tiny boxes and this time I made a mistake. The pivot table and description you refer to can be found here: Apache OpenOffice Community Forum - [Solved] Weekly Sum Of Trade Results Without A Trade Every Day? - (View topic)
Anyway, splitting equally structured data across sheets is very common mistake. One sheet per client, one sheet per month, one sheet per project etc. You must not do that. Database software and spreadsheets are good at sorting, filtering, aggregating data of one table. Just dump your data into one table and let the software do the rest.
Since you asked for a macro in the first place, I can offer one to Merge sheets of one spreadsheet document and another one to Merge sheets of spreadsheet documents.

1 Like

Try this: AGGREGATE()
AlternativeToPivot.ods (16.1 KB)

1 Like