Google Charts API - QR code with leading zeros - google-sheets

I am inserting the following into cell A1 - generate a QR code from the text in both B1 and B2:
=image("https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=" & B1 & "%0A" & B2)
An example might be
B1= TAG
B2= 000000501
I am using a formula for other cells to add one to create an automatic number sequence based on the first value (e.g., B4=SUM(B2+1); B6=SUM(B4+1), etc.).
I would like the resultant QR scan to read "TAG000000501", but the leading zeros are not displayed (e.g., "TAG501". I know how to have the leading zeros displayed regularly by inserting an ' at the beginning of the number, or by changing the cell type to text or a special format with those six leading zeros. It seems the formula forces it to be a number in the API, which results in dropping the zeros.
Any ideas?
Thanks much for your time!

Try this:
=image("https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=" & CONCAT(B1;REPT("0";9-LEN(B2));B2))

Related

How to calculate Dimensions from a Text String in a single cell?

I am need to calculate the dimensions from cell values that are entered as strings into a single cell vs. 3 separate cells and I do not want to break the dimensions into Length (L) x Width (W) x Height (H) Columns.. instead I am hoping there is a relatively simple function that would allow me to calculate the total cubic dimensions from that single cell.
I am aware of this tutorial that can take a string and be used to break it into 3 separate cells.. but that defeats the point of what I am trying to do.
My data looks like this:
Dimensions
Cub/In.
CF
70x13x13
11830
6.85
24*18*13
5616
3.25
24x16x12
16x24x10
Right now the data is entered as either "LxWxH" or "L*W*H" in that text formant and the columns that have values like the 5616 above are me manually re-entering "=24*18*13".. literally one character difference.
I did try a CONCATENATE to just append an "=" to the beginning but got errors on all in Google Sheets (for comparison) or a Literal string into processed as a formula in Excel.
=CONCATENATE(“=”,B1)
Looking for a simple way to do this calculation in a single column and being able to have to enter the data once or utilize the existing data. I don't mind doing a single bulk replace of "x" to "*" on the input column to standardize the source column but don't want to have to do a series of bulk replaces every time I want to run through the data.
Thoughts?
Use SUBSTITUTE to get them all to the same, then use SPLIT and wrap in PRODUCT:
=PRODUCT(SPLIT(SUBSTITUTE(A2,"*","x"),"x"))
Or shorter Version shown by #JvdV:
=PRODUCT(SPLIT(A2,"*x"))

Adding the first digit(s) of a cell ending with specific letter

I have a sheet that has blocks of cells. I add them for a total if they don't contain any letter. Letters signify a specific variable or signifier code for tracking. I also want to add the cell value when a cell has an ending code letter. I've tried SUMIF, Substitute, SumProduct and a few others.
For a while I've used the following which worked till the S value changed to another number than "8" which then gave the wrong sum from the range.
=if(countif(D64:Q64,"*S")=0,"",((countif(D64:Q64,"*S"))*8))
In the cell range I have 5 variable groups ending in a letter (A, H, S, C and R) and one group not ending in any letter.
The formula I use to add the cells not containing a letter but have a value is this
=IF(SUM(AA64,(SUMIF(D65:Q65,"<>")),-(COUNTIF(D65:Q65,">=0")*8))>24,24,(SUM(AA64,(SUMIF(D65:Q65,"<>")),-(COUNTIF(D65:Q65,">=0")*8))))
which adds the table data plus the previous lines table data but does not exceed 24.
H is a set value of 6 and doesn't change.
Does anyone know how to add the value of the cells that contain a specific letter?
N (number)
A
S
C
R
H
8.5
H
8A
2S
9
3C
0.5R
17.5
8
2
3
0.5
6
I'd prefer it be a formula usable in Google Sheets because that is where this data is.
Solution:
You can use this formula below column "N" then drag right until below column "H".
=SWITCH(H$1,"N",SUM($A2:$G2),"H",6,SUM(IFERROR(ARRAYFORMULA(VALUE(LEFT($A2:$G2,FIND(H$1,$A2:$G2)-1))),0)))
This is a combination of three formulas:
If the row above is N, sum A2 to G2. This will ignore all the strings.
If the row above is H, output 6.
Else, get the number to the left of the defined suffix, set all others to 0, and get the sum.
Output:
References:
Extract number from string in Google Sheets
An alternative could be to use
=SUMPRODUCT(A3:G3, isnumber(A3:G3))
to compute the sum of the cells with numbers only, and to use
=sum(filter(substitute($A$3:$G$3, I$2,)+0, regexmatch($A$3:$G$3, I$2)))
under the 'A' and drag to the right
Examples

How to apply formulas in rows with unknown no of columns?

This works:
This does not:
I don't know why.
EDIT:
Thanks to Marios this works:
=ARRAYFORMULA( IF(B5:5 = "Start","",IF(
B6:6-A6:6>-1,B6:6-A6:6,0)))
"Start" to be changed to a named range with the actual date at the top of the sheet.
Explanation:
You are trying to execute this formula:
=ARRAYFORMULA(C6:6-B6:6)
in cell C7.
The issue with that is this part B6:6. This is a range of columns starting from B until the last column in your sheet, but since you put that formula in cell C7 your starting point is column C.
Essentially, you want to put the range of values from column B until the last column of the sheet but your available space is from C until the last column of the sheet and therefore you lack 1 column as the error also suggests.
An analogy would be:
fit a big box inside of a smaller one with a size difference of one column. In this case the big box is the range of B6:6 and you are trying to put it in a smaller box of a range C6:6.
Solution:
Try to put that formula on cell B7 and it will work. Don't drag it, because the big range will shift to column A and you will face the same issue. Just use the same exact formula on cell B7:
=ARRAYFORMULA(C6:6-B6:6)
While this might not be your goal, it explains what is the current issue you are facing and what to do in order to fix it.
Update based on your solution:
=ARRAYFORMULA(iferror(IF(B5:5 = "Start","",IF(B6:6-A6:6>-1,B6:6-A6:6,0)),""))
I added an iferror check to catch the first error value caused by the string.
You should use this:
=ARRAYFORMULA(IF(B5:5 = "Start","",IF(B6:6-A6:6>-1,B6:6-A6:6,0)))

Issue with conditional formatting cell range based on exact match text in one cell

We track workshop registrations in a google sheet and I'm trying to conditionally format a range of cells (A7:P14) based on the text in cell E7 (Eng DLO, Eng TBC, Sp DLO, Sp TBC).
I used the formula
=COUNTIF($E7:$E, "Eng DLO")
and A7:S14 turned the selected color (light purple). When I then added conditional formatting to turn dark purple with the formula
=COUNTIF($E7:$E, "Eng TBC")
the color wouldn't change when I changed the value in E7 from Eng DLO to Eng TBC.
I know the issue is that I need it to EXACTLY MATCH the text and I tried incorporating EXACT into the COUNTIF formula, but it would only highlight E7 or just A7:P7 instead of the whole selected range in the conditional format (A7:P14).
Here is a sample sheet with what I am hoping it will eventually look like once I get the conditional formatting to actually work (I removed the conditional formatting). https://docs.google.com/spreadsheets/d/1Bn9FVTHE1OO49p4PKo6j0Qd3c0NX6pUq3vp0pHFNGVI/edit?usp=sharing
Got a couple other issues here:
The 7 is a floating reference, so you need to fix it with $. This is the reason your formula isn't working. In the next row, it would start counting in cell E8. With the $, it works, but less efficiently than it could, which brings me to point 2.
If you're only referencing one cell, just check for equality against that one cell.
To the Eng TBC, you would use
=EXACT($E$7, "Eng TBC")
Just to demonstrate a point, without the dollar sign, the next rows cells would have been checking against this:
=EXACT($E8, "Eng TBC")
Which of course would have been empty.
A More Flexible Solution
Since you probably don't want to keep having to reformat per set of cells, you can use a ROW-based approach to tackle the issue. This one, for example, assumes 8 seats per group.
=EXACT("Eng DLO",INDIRECT("E"&(8 * INT((ROW() - 7) / 8) + 7)))
Every 8 rows, it references the next multiple of 7. (Yes, INT is FLOOR, but shorter.)

How to delete empty cells and shift up in Google Sheets?

Is there a way to delete empty cells in a given range and shift the column up to the desired display as shown below? Closest I came was
=ARRAYFORMULA({A1:C1; TRANSPOSE(SPLIT(TRANSPOSE(QUERY(A2:C,,999^99)), " "))})
which removes empty cells, but splits the first names and surnames into separate cells, which I have not figured out how to avoid. Pfa a made-up sample of current and desired displays:
Current Display
Desired Display
I'm new at this, but I came up with a bit of a brute force method, which may help you.
={
{(A1:C1)};
{FILTER(A2:A100,A2:A100<>"");indirect("N1:N" & 100-counta(A2:A100))},
{FILTER(B2:B100,B2:B100<>"");indirect("N1:N" & 100-counta(B2:B100))},
{FILTER(C2:C100,C2:C100<>"");indirect("N1:N" & 100-counta(C2:C100))}}
Assuming your data block is in columns A1:C100, this formula filters blank cells from each individual column, and then pads each column with blank cells at the bottom, to make the three arrays equal in length/dimension.
Note that in "100-counta(...", the 100 is the expected maximum length of your data column.
This could be calculated, and must be the same for all three columns.
Note also that the first array is horizontal (ends with a semi-colon), followed by the three columns, stacked beside each other (ends with a comma).
Here is a working example.
https://docs.google.com/spreadsheets/d/1MGaqqGrkmIliuAzEqxPtdEVZXWPN2K5W7jFFM-ZnwgE/edit?usp=sharing
If I missed something you were trying to achieve, let me know.
Also, I'm sure that there is a more elegant way to do this, or one not requiring the use of a block of "reserved" blank cells, but I couldn't think of that at the moment.
Edit: The formula as follows also works. But you need to remember to set the "100" value to be equal to the number of rows in your data block, since we pad the columns with the necessary number of blanks rows, after removing the blank cells in each column.
={
{(A1:C1)};
{FILTER(A2:A,A2:A<>"");indirect("N1:N" & 100-counta(A2:A))},
{FILTER(B2:B,B2:B<>"");indirect("N1:N" & 100-counta(B2:B))},
{FILTER(C2:C,C2:C<>"");indirect("N1:N" & 100-counta(C2:C))}}

Resources