[Solved] Sum another column with COUNTIF

Discuss the spreadsheet application
Post Reply
vazz-the-buzz
Posts: 1
Joined: Sun Dec 25, 2022 10:37 pm

[Solved] Sum another column with COUNTIF

Post by vazz-the-buzz »

Hello,
I use this command to get specific numbers from the T coloumn.

=COUNTIF(DCA.T5:T20000;">=1.2")-COUNTIF(DCA.T5:T20000;">=1.25")

Now I want to sum the numbers on the B column who correspond to the above result. If the COUNTIF on T column find numbers on row 4,5 and 9, I'd like the numbers of the column B and rows 4,5 and 9 return a sum.
Is it possible?

Cheers

 Edit: Changed subject, was Get the Sum of two different colunms with CountIF 
Make your post understandable by others 
-- MrProgrammer, forum moderator 
Last edited by MrProgrammer on Wed Dec 28, 2022 4:41 am, edited 3 times in total.
Reason: Edited topic's subject
OpenOffice 4 on Windows 11
User avatar
karolus
Volunteer
Posts: 1252
Joined: Sat Jul 02, 2011 9:47 am

Re: Get the Sum of two different colunms with CountIF

Post by karolus »

Hallo

Code: Select all

=SUMIF(DCA.T5:T20000 ; "1\.2([0-4][0-9]*)?" ; DCA.B5:B20000)
you probably need to …: →→Tools→Options→→Calc→calculate→→[x]allow regular Expressions in Formulas

ps. the same RegEx as above would also work in your COUNTIF -example
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
User avatar
MrProgrammer
Moderator
Posts: 5468
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Get the Sum of two different colunms with CountIF

Post by MrProgrammer »

vazz-the-buzz wrote: Sun Dec 25, 2022 10:49 pm Now I want to sum the numbers on the B column who correspond to
=COUNTIF(DCA.T5:T20000;">=1.2")-COUNTIF(DCA.T5:T20000;">=1.25")
karolus wrote: Mon Dec 26, 2022 8:10 am =SUMIF(DCA.T5:T20000 ; "1\.2([0-4][0-9]*)?" ; DCA.B5:B20000)
you probably need to …: →→Tools→Options→→Calc→calculate→→[x]allow regular Expressions in Formulas
If the values in column T are numbers, as opposed to text, =SUMPRODUCT(DCA.B5:B20000;DCA.T5:T20000>=1.2;DCA.T5:T20000<1.25)
will work with either setting of Allow Regular Expressions in Formulas. I have assumed that "the B column" also refers to sheet DCA.

If you need any additional assistance attach a spreadsheet demonstrating the difficulty (remove confidential information then use Post Reply, not Quick Reply, and don't attach a picture instead of the spreadsheet itself). I will not help further unless you attach.

[Tutorial] The SUMPRODUCT function, example X01. Conditional Summing
[Tutorial] Ten concepts that every Calc user should know, section 1. Types of data

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the Subject field. Select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
Post Reply