This should be easy. I can quickly figure out the FOREACH/IF statement, but I can't translate that to spreadsheet-ese. I want to go down row by row and compare if the value in one cell is less than the value in another cell. If that condition is true, increment the counter and check the next row.
So, given:
$38.88 | $38.88
$41.40 | $93.56
$92.65 | $104.69
$143.10 | $143.10
$59.40 | $59.45
$59.40 |
$63.50 | $0.00
the answer is 2 (Rows 6 & 7).
I could then change the criteria to A > B and get the answer 3 (Rows 2, 3, & 5). Empty cells (Row 6) are equal to 0.
Thank you in advance.
[Solved] Count of A1<B1 or A2<B2 or A3<B3 ...
[Solved] Count of A1<B1 or A2<B2 or A3<B3 ...
Last edited by Hagar Delest on Mon May 06, 2024 6:25 pm, edited 1 time in total.
Apache OpenOoffice 4.1.5-m1 (Build:9789) on Windows 10 Home
Re: Counting when A1 < B1 or A2 < B2 or A3 < B3 ...
SUMPRODUCT() may be a solution; see for example X29 in [Tutorial] The SUMPRODUCT function.
Slackware 15 (current) 64 bit
Apache OpenOffice 4.1.16
LibreOffice 26.2.3.2; SlackBuild for 26.2.3 by Eric Hameleers
---------------
I hate this damn computer, I wish that I could sell it.
It won't do what I want it to, Only what I tell it.
Apache OpenOffice 4.1.16
LibreOffice 26.2.3.2; SlackBuild for 26.2.3 by Eric Hameleers
---------------
I hate this damn computer, I wish that I could sell it.
It won't do what I want it to, Only what I tell it.
- MrProgrammer
- Moderator
- Posts: 5431
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: Counting when A1 < B1 or A2 < B2 or A3 < B3 ...
Spreadsheets do not have FOREACH statements.
Spreadsheets do not have IF statements.
Spreadsheets do not have any statements at all! Instead, they use formulas.
[Tutorial] Ten concepts that every Calc user should know
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.
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).
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).
Re: Counting when A1 < B1 or A2 < B2 or A3 < B3 ...
@MrProgrammer
Sorry, but in [Tutorial] The SUMPRODUCT function which you wrote five years ago, you have a typo in the second paragraph where you say "Let's take a look at an example so you can wee why these values are important."
I also found "equais" in X29 and X30.
There may be others, but I was just skimming for relevant information.
Thanks.
Sorry, but in [Tutorial] The SUMPRODUCT function which you wrote five years ago, you have a typo in the second paragraph where you say "Let's take a look at an example so you can wee why these values are important."
I also found "equais" in X29 and X30.
There may be others, but I was just skimming for relevant information.
Thanks.
Apache OpenOoffice 4.1.5-m1 (Build:9789) on Windows 10 Home
[SOLVED] Counting when A1 < B1 or A2 < B2 or A3 < B3 ...
@robleyd - Thanks so very much for your guidance. I appreciate your assisting me to find a plausible, yet cryptic, solution. You are awesome!
A real superstar!
By name alone, I would never have thought to use a function called SUMPRODUCT. Google's AI couldn't equate comparing values in Calc to SUMPRODUCT so searches weren't helpful either. OpenOffice Calc isn't very user-friendly so it is vital to have great people like you to help others.
You have my undying gratitude, sir.
By name alone, I would never have thought to use a function called SUMPRODUCT. Google's AI couldn't equate comparing values in Calc to SUMPRODUCT so searches weren't helpful either. OpenOffice Calc isn't very user-friendly so it is vital to have great people like you to help others.
You have my undying gratitude, sir.
Apache OpenOoffice 4.1.5-m1 (Build:9789) on Windows 10 Home
- MrProgrammer
- Moderator
- Posts: 5431
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: [Solved] Counting when A1 < B1 or A2 < B2 or A3 < B3 ...
SUMPRODUCT is an important function with many uses, as you've seen in the tutorial. I would think that most of the Introduction to Spreadsheets books which one might study would explain it in later chapters. But columns D and F use simple formulas to determine the counts; they just use the < or > operators with the SUM function. That is the technique that I would suggest for beginners.
I appreciate your assistance in improving the tutorial. Thank you.
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).
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).