So I'm making a spreadsheet to track my macros in an attempt to eat healthier.
="Calories: "&SUMPRODUCT(IFERROR(ARRAYFORMULA(REGEXEXTRACT(B5:L5, "([0-9]+)cal")), 0)) &char(10)& "Protein: "&SUMPRODUCT(IFERROR(ARRAYFORMULA(REGEXEXTRACT(B5:L5, "P: ([0-9]+)g")), 0))&"g"
This looks at the information given in the cells (E.G. "Salad 320cal P:32) and parses out the data based on the prefix and suffix of the given data.
I would like to make this process even simpler, mainly by using an array of already made data, and using the title of the phrase ("Salad") to call to the data in the array just by typing in the cells.
Is there any setup or function I can use to reroute the data to an array based on a string?
Here is a link to a copy of my spreadsheet with a hopefully more clear set of instructions
https://docs.google.com/spreadsheets/d/1dWu4UKlZdvK_1ZjM8dNb-l87RXmhs8eB7k4B2Bk0ATs/edit?usp=sharing
try vlookup:
=ARRAYFORMULA(IFNA(VLOOKUP(B3:L3, O11:P21, 2, 0)))
and use it as input for your total formula
Use this formula
=ArrayFormula(IF(B1:1="Total",
IF(B3:3="",,
"Calories: "&SUM(IFNA(REGEXEXTRACT(IFNA(VLOOKUP(LOWER(B3:3), LOWER($O$12:$P), 2, 0), "No Description"), "([0-9]+)cal"),"")*1)& CHAR(10) &
" Protien: "&SUM(IFNA(REGEXEXTRACT(IFNA(VLOOKUP(LOWER(B3:3), LOWER($O$12:$P), 2, 0), "No Description"), "([0-9]+)g" ),"")*1)& " g"),
IF(B3:3="",,IFNA(VLOOKUP(B3:3, $O$12:$P, 2, 0), "No Description"))))
Slightly complex problem, but hopefully manageable.
Refer to this demo document before reading as I'll be referring to it throughout this post.
What I'm trying to accomplish:
As seen in the demo document, I'm trying to insert "Sticker" images automatically if the following statements are correct:
Within the "Master Sheet" sheet; If the "SKU" number (column 'E') is found on the 'PRICE CHANGE' sheet, Then look under Column 'K' on the 'PRICE CHANGE' sheet.
Within the 'PRICE CHANGE' sheet; If the start of the of the text (on column 'K') start's with a number, find the number that matches on the 'Sticker Images' sheet under column 'B' and insert the image of the corresponding "Sticker" into the "Master Sheet" sheet.
In spoken terms: I want to fetch data from 'Master Sheet' sheet, refer that data to the 'Price Change' sheet, fetch more data from the 'Price Change' sheet, then refer that data to the 'Sticker Images' sheet, then finally bring the correct image from the 'Sticker Images' sheet and place the image in its correct spot on the 'Master Sheet' sheet.
Here are some visuals if my explanation still wasn't good enough 😂
The problem I'm having: I can't seem to find a way to make the formula understand I'm looking for just the single value only at the START of the text on column 'K' within the 'PRICE CHANGE' sheet.
Here is the formula I'm using at the moment:
=IFERROR( VLOOKUP( IFERROR( LEFT( VLOOKUP( $E12, 'PRICE CHANGE'!$E$18:AC25, 12, 0), 1)), 'Sticker Images'!B:C, 2, 1))
Things to keep in mind:
I cannot edit the 'PRICE CHANGE' sheet in any way.
The "Men's Ultraboost 22 Running Shoe" should have a yellow sticker and the "Women's GEL-Kayano® 28 AWL Running Shoe" should have a red one (Just for validation/Check your work).
Thanks in advance for any answers/help!
You can use a single, simplified formula for all.
Within your Master SheetClear everything in the range F12:F and place this formula in cell F12
=INDEX(IFERROR(VLOOKUP(LEFT(
VLOOKUP(E12:E,'PRICE CHANGE'!E19:K,7,0)),'Sticker Images'!B:C,2)))
Try this
=IFERROR( VLOOKUP( IFERROR( LEFT( VLOOKUP( $E12, 'PRICE CHANGE'!$E$18:AC, 7, 0), 1)), 'Sticker Images'!B:C, 2, 1))
Keep the vlookup range open ended 'PRICE CHANGE'!$E$18:AC
The index in your formula is set to 12 is suppose to be set 7 to get the column K .
The existing formula already works, as long as typo (or typo-like) errors are fixed:
=VLOOKUP(LEFT(VLOOKUP($E12, 'PRICE CHANGE'!E:K, 7, 0), 1)), 'Sticker Images'!B:C, 2, 1))
Note the 7 instead of 12. The key thing is to fix the column index for range E:K. (And have the correct row index for that range, and correct fixed vs iterative indices choices. I also changed AC to K since you only are referring to column K. May as well avoid a potential source of error by referring a larger range than you intend to have sheet content.)
I did test using Google Sheet. No guarantee how things turn out in Excel.
I don't usually post an answer for fixing small errors. The OP has everything correctly set up already. But posted nonetheless as requested.
I am trying to grab advertising expenses for the day on the basis of country groups.
The date, and country for the record are in columns I, J and G respectively.
I am doing a VLOOKUP that references a sheet called advertising,
with the search key being a date and month together, and picking up the value column based on the country.
Then in order to average it out, I am dividing this lookup, which gives me the ad spend for a set of countries by the number of records for that date, month and country.
=(IF(OR(G4="Spain",G4="Portugal"),VLOOKUP(I4&J4,Advertising!$A$3:$AK,32,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Spain","Portugal"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Spain","Portugal"}),0),
IF(G4="France",VLOOKUP(I4&J4,Advertising!$A$3:$AK,33,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"France"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"France"}),0),
IF(G4="Italy",VLOOKUP(I4&J4,Advertising!$A$3:$AK,34,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Italy"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Italy"}),0),
IF(OR(G4="Belgium",G4="Netherlands"),VLOOKUP(I4&J4,Advertising!$A$3:$AK,35,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Belgium","Netherlands"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Belgium","Netherlands"}),0),
IF(G4="Sweden",VLOOKUP(I4&J4,Advertising!$A$3:$AK,36,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Sweden"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Sweden"}),0),
IF(G4="United Kingdom",VLOOKUP(I4&J4,Advertising!$A$3:$AK,37,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"United Kingdom"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"United Kingdom"}),0),
VLOOKUP(I4&J4,Advertising!$A$3:$AK,31,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Germany","Austria","Bulgaria","Croatia","Cyprus","Australia","Denmark","Estonia","Finland","Greece","Hungary","Ireland","Latvia","Lithuania","Luxembourg","Malta","Norway","Romania","Russia","Slovakia","Slovenia","Switzerland","UAE"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Germany","Austria","Bulgaria","Croatia","Cyprus","Australia","Denmark","Estonia","Finland","Greece","Hungary","Ireland","Latvia","Lithuania","Luxembourg","Malta","Norway","Romania","Russia","Slovakia","Slovenia","Switzerland","UAE"}),0)
)))))))
Unfortunately, this is returning an error for me.
As you can see, I have an IF clause to avoid division by zero.
However, I have somehow convinced myself that the error is being reurned in the averaging (i.e. division with the COUNTIFS) process, not in the VLOOKUP. I do believe my COUNTIFS are illegitimately and unexplainably returning zero.
e.g. for row 4 in the main sheet, which I have posted above,
=COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Germany","Austria","Bulgaria","Croatia","Cyprus","Australia","Denmark","Estonia","Finland","Greece","Hungary","Ireland","Latvia","Lithuania","Luxembourg","Malta","Norway","Romania","Russia","Slovakia","Slovenia","Switzerland","UAE"})
returns a zero. When I test it out with fewer countries, always including Austria, sometimes it returns zero, sometimes 1.
A sample sheet is at https://docs.google.com/spreadsheets/d/1YgK_D7FaTWtKcSts2uDiG7jlTRx2_IGrJ41wZr2qyak/edit?usp=sharing
P.S. I do not have enough reputation, but I would request one of the seniors to add "countifs" tag.
try in row 4:
=INDEX(IFNA(VLOOKUP(I4:I&"×"&J4:J,
{Advertising!B3:B&"×"&Advertising!C3:C, Advertising!B3:AK},
MATCH(G4:G, Advertising!A1:1, ), )))
update:
=INDEX(IFERROR(1/(1/(IFNA(VLOOKUP(I4:I&"×"&J4:J,
{Advertising!B3:B&"×"&Advertising!C3:C, Advertising!AE3:AK}, MATCH(IFNA(VLOOKUP(G4:G,
{{"France";"Germany";"Austria";"Bulgaria";"Croatia";"Cyprus";"Australia";"Denmark";"Estonia";"Finland";"Greece";"Hungary";"Ireland";"Latvia";"Lithuania";"Luxembourg";"Malta";"Norway";"Romania";"Russia";"Slovakia";"Slovenia";"Switzerland";"UAE";"Italy";"Belgium";"Netherlands";"Spain";"Portugal";"Sweden";"United Kingdom"},
{"France";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Italy";"Netherlands";"Netherlands";"Spain";"Spain";"Sweden";"United Kingdom"}},
2, )), Advertising!AD1:AK1, 0), ))/
COUNTIFS(I4:I&"×"&J4:J&IFNA(VLOOKUP(G4:G,
{{"France";"Germany";"Austria";"Bulgaria";"Croatia";"Cyprus";"Australia";"Denmark";"Estonia";"Finland";"Greece";"Hungary";"Ireland";"Latvia";"Lithuania";"Luxembourg";"Malta";"Norway";"Romania";"Russia";"Slovakia";"Slovenia";"Switzerland";"UAE";"Italy";"Belgium";"Netherlands";"Spain";"Portugal";"Sweden";"United Kingdom"},
{"France";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Italy";"Netherlands";"Netherlands";"Spain";"Spain";"Sweden";"United Kingdom"}},
2, )), I4:I&"×"&J4:J&IFNA(VLOOKUP(G4:G,
{{"France";"Germany";"Austria";"Bulgaria";"Croatia";"Cyprus";"Australia";"Denmark";"Estonia";"Finland";"Greece";"Hungary";"Ireland";"Latvia";"Lithuania";"Luxembourg";"Malta";"Norway";"Romania";"Russia";"Slovakia";"Slovenia";"Switzerland";"UAE";"Italy";"Belgium";"Netherlands";"Spain";"Portugal";"Sweden";"United Kingdom"},
{"France";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Italy";"Netherlands";"Netherlands";"Spain";"Spain";"Sweden";"United Kingdom"}},
2, )))))))
or like this:
=INDEX(IFERROR(1/(1/(IFNA(VLOOKUP(I4:I&"×"&J4:J,
{Advertising!B3:B&"×"&Advertising!C3:C, Advertising!AE3:AK},
MATCH(IFNA(VLOOKUP(G4:G, Sheet3!A:B, 2, )), Advertising!AD1:AK1, 0), ))/
COUNTIFS(I4:I&"×"&J4:J&IFNA(VLOOKUP(G4:G, Sheet3!A:B, 2, )),
I4:I&"×"&J4:J&IFNA(VLOOKUP(G4:G, Sheet3!A:B, 2, )))))))
Use match(), like this:
=arrayformula(
iferror(
vlookup(
I4:I & J4:J,
{ Advertising!B3:B & Advertising!C3:C, Advertising!B3:AK },
match(G4:G, Advertising!A1:AK1, 0),
false
)
)
)
See the new Solution sheet in your sample spreadsheet. The formula is in cell P4.
Note that not all the country names in your search keys are present in the data.