Automatically add standard strings either side of variable strings - function

I have a library of flags online that I use in a spreadsheet. The current function looks like this:
=image("http://www.website.com/images/Flags/us.png", 3)
I would like to apply a rule or a function to an entire column so that I just need to write us and it automatically adds this before:
=image("http://www.website.com/images/Flags/
and this after:
.png", 3)
Is this even possible?

Certainly. If you put the two 'standard components' into say B1 and C1 as shown below then:
=B$1&A3&C$1
should serve to concatenate the three elements to suit provided the us is in A3. The formula can be copied down to wrap the standard components around other values in ColumnA, if required:

Related

How can I make a formula in Google Spreadsheet to return a value if a cell contains a text in a list

I'm currently interested in building a custom function/formula in Google Spreadsheet where the function will intake a cell and return a value that is related to a specific text in a list.
As you can see in the screenshot, which is a demo that I drafted to give a better idea of what I'm trying to accomplish, column A contains a list of items that has random texts. In the texts, there are some keywords that I would like to identify into different categories.
Column B is just a demo of how I envision to use my custom function that I want to create. Column C is the expected result that I would get by using the custom function.
Column E is the list of keywords that I would like the custom function to search for in cells and Column F is the category that I would like the custom function to return once it finds the relevant keyword in a text.
Thank you!
I tried searching for this topic, but I only came across how to set up an array formula to achieve what I want to do. If there was any post about this, I would really appreciate if you could just link it in the comment.
Given your scenario, you can try with this formula:
=FILTER(F:F,INDEX(REGEXMATCH(A2,"(?i)"&E:E)),E:E<>"")
If you wish to have it for the whole row:
=BYROW(A2:A,LAMBDA(each,IF(each="","",FILTER(F:F,INDEX(REGEXMATCH(each,"(?i)"&E:E)),E:E<>""))))
If you could have more than one result, you can add JOIN:
=BYROW(A2:A,LAMBDA(each,IF(each="","",JOIN(", ",FILTER(F:F,INDEX(REGEXMATCH(each,"(?i)"&E:E)),E:E<>"")))))

Google Sheets - Combine multiple IF Functions into one cell

I'm trying to produce a SKU in Google Sheets for a product using the values of three variants (Title, Colour and Size)
The product is 'Lightweight trainers' with colour variants of 'Red' and 'Blue', and the sizes range from 5 - 12.
Link to spreadsheet
https://docs.google.com/spreadsheets/d/1trq0X3MjR-n2THFnT8gYYlwKscnQavCeeZ8L-ifYaHw/edit?usp=sharing
Aim
I'm hoping to have a SKU that displays the product, the colour variant and the shoes size.
Example: LW-1-8 (Lightweight trainer, colour Red, size 8)
Product is Lightweight Trainers with a value of LW.
Colour variant 'Red' with a value of 1 and 'Blue' with a value of 2.
Shoe size variant = number ranging from 5 to 12.
Here's what I have so far, joining the colour and size variants.
=IFS(I2="Red",1,I2="Blue",2)&"-"& IFS(K2="5",5,K2="6",6,K2="7",7,K2="8",8,K2="9",9,K2="10",10,K2="11",11,K2="12",12)
However, I'm getting stuck in joining the data in column B with this function.
Any help with combining this data from multiple cells into one would be greatly appreciated.
TL;DR
=ARRAYFORMULA(IF(B2:B<>"", IFS(B2:B="Lightweight Trainers", "LW")&"-"&IFS(I2:I="Blue", 1, I2:I="Red", 2)&"-"&K2:K,))
Answer
What you want is basically:
<title>-<color number>-<shoe size>
To convert this to a function we can split it into each part and take it step by step:
Step 1: Title
For the first part -the title- we need to match the value with the shorthand. A simple list in an IFS is enough.
IFS(B2="Lightweight Trainers", "LW")
Obviously for now it only has a single value (Lightweight Trainers) but you could add more:
IFS(B2="Lightweight Trainers", "LW", B2="Heavyweight Trainers", "HW")
Step 2: color number
Similar to the previous step, it’s a mapping using ifs:
IFS(I2="Blue", "-1", I2="Red", "-2")
The dash is added so when adding everything it will only have it if
Step 3: shoe size
In this case we can simply get the value:
K2
Step 4: Adding everything together
We only need to add it with the dashes in between:
=IFS(B2="Lightweight Trainers", "LW")&"-"&IFS(I2="Blue", 1, I2="Red", 2)&"-"&K2
Step 5: Extending for the entire column automatically
We will use ARRAYFORMULA to add a single formula to the first cell and get it automatically extended to the entire column. We first add it to the formula we already have, and then extend the ranges to the entire column:
=ARRAYFORMULA(IFS(B2:B="Lightweight Trainers", "LW")&"-"&IFS(I2:I="Blue", 1, I2:I="Red", 2)&"-"&K2:K)
Remember to remove all the values in the column so array formula doesn’t override them (it would generate an error).
As you can see the formula generates errors for the rows that have no values. A good way of handling this case is to filter the rows without a title. In a single row would be:
=IF(B2<>"", [the entire formula],)
Notice the last comma.
So putting everything together and extending its range to the column, is:
=ARRAYFORMULA(IF(B2:B<>"", IFS(B2:B="Lightweight Trainers", "LW")&"-"&IFS(I2:I="Blue", 1, I2:I="Red", 2)&"-"&K2:K,))
Adding this to N2 should work.
Final notes
It seems that you use 150 when the size it’s not a whole number. If you want to keep that functionality you may use:
IF(K2-int(K2)=0, K2, 150)
On the last component and expand it the same way.
You may also want to prevent having two dashes when a value is missing (LW-5 instead of LW--5). To do so, I’d recommend adding it to each component instead of the formula that adds them together.
References
IFS (Docs Editors Help)
IF (Docs Editors Help)
ARRAYFORMULA (Docs Editors Help)
try in N2:
=IFS(I2="Red",1,I2="Blue",2)&"-"&
IFS(K2=5,5,K2=6,6,K2=7,7,K2=8,8,K2=9,9,K2=10,10,K2=11,11,K2=12,12)
or use:
=IF(I2="red", 1, IF(I2="blue", 2, )&IF((K5>=5)*(K5<=12), "-"&K5, )

Filtering name with two condition

I have a sample list of student and grades/subject in this file
enter image description here
https://docs.google.com/spreadsheets/d/1NeHlUaRnbvdJ2yJ38fUETGgBoYseQ8CuXmwRCwObAlM/edit#gid=0
On the range A16:A I'd like to see the list of names who has the grades of around 90-100 when I check any of the checkbox on B15:k15
the first example is when I check all of the boxes
I will only see the first name on the list because he is the only one with the 90-100 scores on all subject
2nd example when I check B15 and C15
I will only see the 1st and 2nd names on the list because he's those who only able to get a 90-100 score on those two subjects.
Is there a way to do this kind of filtering? thank you so much
Since this is your first post, I'm going to go with the approach I think you'll find easiest to understand. It's a long formula (which I've placed in a new sheet called "Erik Help" in A16), but it's just a repeat of the same element several times:
=FILTER(A2:K11, IF(B15=TRUE, B2:B11>=90, B2:B11^0), IF(C15=TRUE, C2:C11>=90, B2:B11^0), IF(D15=TRUE, D2:D11>=90, D2:D11^0), IF(E15=TRUE, E2:E11>=90, E2:E11^0), IF(F15=TRUE, F2:F11>=90, F2:F11^0), IF(G15=TRUE, G2:G11>=90, G2:G11^0), IF(H15=TRUE, H2:H11>=90, H2:H11^0), IF(I15=TRUE, I2:I11>=90, I2:I11^0), IF(J15=TRUE, J2:J11>=90, J2:J11^0), IF(K15=TRUE, K2:K11>=90, K2:K11^0))
The first argument of FILTER tells the function what to filter (in this case A2:K11).
After that, an IF statement is set up to check each checkbox. If the checkbox is checked, the FILTER will only include students who obtained a 90 or higher in that subject.
If the checkbox is NOT checked, then the student is automatically included (that's the part that says "B2:B11^0" etc., since anything to the zero-power equals 1, and 1 and TRUE are the same to Google Sheets). In other words, if no checkboxes were checked, then all students would read TRUE for all subjects, i.e., all students would be included (or, to think of it another way, no one is rules out). While the ^0 is not strictly necessary (i.e., any number other than zero is the same as TRUE), I think it's better formula practice and easier for others to understand if TRUE is represented either as TRUE or as 1.
I also set conditional formatting on A15:A, to bold the name as you had it. (The conditional formatting rule says, in English, "If anything is there, use bold.") You can see the rule by clicking anywhere in the range A15:A, then selecting Format > Conditional formatting from the menu and clicking the open the rule that appears in the window to the right of the screen.

Extracting values next to specific words in Google Spreadsheet

I got a string of data typed in a single cell like this "TIME200629 SYNC-7 CPU13.6", and I am trying to extract values next to the word TIME, SYNC, CPU in separate cells(2020-06-29 10:41:02 in C126, -7 in D126 and 13.6 in E126). What kind of functions or formula can I use to do this?
I can change the original form of string of data(Data(in)) if it is necessary to pull this off.
Assuming your pattern words are only capitalized letters, and no other punctuation, then
In Sheets, you could do something like:
B2: original string
C2: =trim(REGEXEXTRACT($B2,C$1 & "([^A-Z]+)"))
*and fill right to E2*
Adjust the cell references to suit.
Another option would be:
=SPLIT(REGEXREPLACE(B126,"\s*[A-Z]+\s*","|"),"|")
This will spill to the right, and if you want you can include ARRAYFORMULA to splill to the bottom to, e.g.: =ARRAYFORMULA(SPLIT(REGEXREPLACE(B126:B127,"\s*[A-Z]+\s*","|"),"|"))

RDL report - change of header text in CSV export by parameter

I am working on rdl reports and as I had to add multilingual support, I need to be able to change the column headers' text by the selected language parameter.
I added this very basic custom expression to the header:
=IIF(Parameters!Language.Value="EN", "Date", "DateInDifferentLanguage")
but when I export the report to CSV this is completely ignored, moreover, the column header will be the assigned value's name.
I tried to search for solution for almost 2 days, but the only thing I found that I should use the DataElementName property. Well, for static values it works, but as the text is parameter-dependent I have to use custom expressions and this property does not allow me to use anything like that.
Hopefully, there will be no difference in the solution for grouped columns.
So, my question is: is it possible to add parameter-dependent custom expressions to grouped/not grouped columns?
EDIT: I just realized that you can't set the DataElementName property by expression. I'll leave this up in the off-chance that it may help in some way.
If you're wanting different expressions based on a parameter, try this:
Make sure you can see your Report Data. View -> Report Data(at the bottom)
Start by creating the parameter. Right click Parameters folder in the Report Data window -> Add Parameter... Let's call it 'Language'.
In the available values tab, click Specify Values. Add values for your languages, so the label will be what you want the viewer to see, make the value the same.
Label: English
Value: english
In the Expression you're trying to modify, simply put the available expressions you want in an SWITCH() block.
SWITCH(Parameters!Language.Value = 'english', [do english things],
Parameters!Language.Value = 'spanish', [do spanish things],
Parameters!Language.Value = 'chinese', [do chinese things],
True, [do english things])