[Solved] Use wildcard (asterisk) with SUMIF

Discuss the spreadsheet application
Post Reply
iddqd
Posts: 12
Joined: Sat Oct 08, 2022 9:34 am

[Solved] Use wildcard (asterisk) with SUMIF

Post by iddqd »

I want to calculate the total values in column A via looking for a part of a string in column B

-SUM the A if the values in B contains FOOD
-SUM the A if the values in B contains the letter G
-SUM the A if the values in B contains the DAY

A       B
10	Monday Food
20	Tuesday Gym
30	Wednesday Gym
40	Thursday Shopping for groceries. also food.
50	Friday food
60	Saturday gym
70	Sunday groceries

for example. i tried =SUMIF(B1:B7, "*day*", A1:A7) but it doesn't work.

any help are greatly appreciated.
Last edited by MrProgrammer on Tue May 14, 2024 3:10 pm, edited 2 times in total.
Reason: Added formatting to sample data
OpenOffice 4.1.10 on OS X Monterey 12.5
FJCC
Moderator
Posts: 9314
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Problem using wildcard (asterix) with SUMIF

Post by FJCC »

The following works for me

Code: Select all

=SUMIF(B1:B7; ".*food.*"; A1:A7)
Note that the the wild card is .* and that the parts of the formula are separated by semicolons. OpenOffice uses regular expressions as wild cards and .* means "zero or more of any character". You may have to enable regular expression in formulas under OpenOffice -> Preferences -> OpenOffice Calc -> Calculate.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
iddqd
Posts: 12
Joined: Sat Oct 08, 2022 9:34 am

Re: Problem using wildcard (asterix) with SUMIF

Post by iddqd »

FJCC wrote: Mon May 13, 2024 3:01 pm The following works for me

Code: Select all

=SUMIF(B1:B7; ".*food.*"; A1:A7)
Note that the the wild card is .* and that the parts of the formula are separated by semicolons. OpenOffice uses regular expressions as wild cards and .* means "zero or more of any character". You may have to enable regular expression in formulas under OpenOffice -> Preferences -> OpenOffice Calc -> Calculate.
i could not find this use of wildcards in any documentation. thanks a lot, problem solved.
OpenOffice 4.1.10 on OS X Monterey 12.5
FJCC
Moderator
Posts: 9314
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: [Solved] Use wildcard (asterisk) with SUMIF

Post by FJCC »

The help lists it as "regular expressions;list of", so you have to know what a regular expression is to make the correct search. That's not as helpful as it could be.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Alex1
Volunteer
Posts: 734
Joined: Fri Feb 26, 2010 1:00 pm
Location: Netherlands

Re: [Solved] Use wildcard (asterisk) with SUMIF

Post by Alex1 »

I would recommend to arrange the data in three columns and use a pivot table.
Attachments
Pivottable111543a.ods
(11.42 KiB) Downloaded 25 times
AOO 4.1.15 & LO 24.2.2 on Windows 10
iddqd
Posts: 12
Joined: Sat Oct 08, 2022 9:34 am

Re: [Solved] Use wildcard (asterisk) with SUMIF

Post by iddqd »

Alex1 wrote: Tue May 14, 2024 12:18 pm I would recommend to arrange the data in three columns and use a pivot table.
loved the idea. will definitely use this to make my view clearer. thank you.
OpenOffice 4.1.10 on OS X Monterey 12.5
iddqd
Posts: 12
Joined: Sat Oct 08, 2022 9:34 am

Re: [Solved] Use wildcard (asterisk) with SUMIF

Post by iddqd »

FJCC wrote: Mon May 13, 2024 4:36 pm The help lists it as "regular expressions;list of", so you have to know what a regular expression is to make the correct search. That's not as helpful as it could be.
thank you fjcc
OpenOffice 4.1.10 on OS X Monterey 12.5
Post Reply