Search code examples
excelgoogle-sheetsexcel-formulalibreofficelibreoffice-calc

Excel's version of group by + having


Could you please help me with the following.

If Excel table was a relational database table, this is what I would want to do:

enter image description here

D3 should have a value of 8 and be recalculated whenever rows are added. I am familiar with COUNT/COUNTA and OFFSET functions in case they need to be used. Pivot table will not work, since I don't need all possible A values, just specific one. The solution should work for both Excel and Libre Office. If it also works for Google Sheets, it will be even better.

Thank you for your help.


Solution

  • The following formula should do the trick:

    =sumif(A1:B6, "=x", B1:B6)

    enter image description here

    You can change the ranges to whatever you need