I have a cell A1 contains : 1,5,7
I want to a create a formula in cell A2 which output like this :
8s,40s,56s
So i want to grab value from A1, split it by ',' so then i get the array contains :
1
5
7
I will then multiply each element by 8:
1x8 = 8
5x8 = 40
7x8 = 56
Then add 's' to the output as follow :
8s
40s
56s
Last, i want to concatenate them back using ',' as separator to become :
8s,40s,56s
Thanks
use:
=INDEX(JOIN(",", SPLIT(A1, ",")*8&"s"))
Try this:
arrayformula(textjoin(",",1,transpose(split(A1,","))*8&"s"))
Related
Hi I have 2 formulas in google sheet that works great alone, but how can I put it together and get 1 result in the same cell, not side by side when we use "&"
Formula 1: =COUNTIFS(B1,"<>")*1-COUNTIFS(E1,"<>")*0
(when I have some text in cell B1 and E1 just count cell B1)
Formula 2: =(COUNTIFS(B1,"")*0+COUNTIFS(E1,"<>")*1)
(when I have some text in cell E1 and B1 is blank just count cell E1)
Already tried: =COUNTIFS(B1,"<>")*1-COUNTIFS(E1,"<>")*0&(COUNTIFS(B1,"")*0+COUNTIFS(E1,"<>")*1) unwanted result: 1 1 in the same cell
try:
=IF((B1<>"")*(E1<>""), 1,
IF((E1<>"")*(B1 =""), 1, 0))
I have the following sheet.
H I J K ... BD
2,3 4 2,4,7 ... 1
3,7 10 ... 8,13
The cell ‘H’ has 2,3 as text but cell ’I’ has the number 4, cell ‘J’ has the 2,4,7 as text and cell ‘BD’ has 1 as a number. All the cells that have 2 or more numbers as text are separated by commas
I want to sum all numbers and non-numbers to one single row using array-formula.
The result must be
BE
16
41
The range is between H2:BD with H1:BD1 for the headers
I have used this code:
=arrayformula(if(row(A1:A)=1;"BottleQty";if(len(A1:A)>0;
SUBSTITUTE(transpose(query(transpose(H1:BD);;COLUMNS(H2:BD)));",";"");iferror(1/0))))
but the result is
BE
2 3 4 2 4 7 1
3 7 10 8 13
Any help ??
Thanks in advance
=ARRAYFORMULA(IF(LEN(TRIM(TRANSPOSE(QUERY(TRANSPOSE(A2:D),,99^99)))),
MMULT(IFERROR(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(A2:D),,99^99)), ", ")*1, 0), ROW(INDIRECT("A1:A"&
COLUMNS(IFERROR(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(A2:D),,99^99)), ", ")*1, 0))))^0), ))
I have this data:
data2 is missing the third point. So I thought, I'd define two different x columns and assign data2 to x2.
Problem: the third point of data1 goes up to 3 in the compiled graphic. If I have different and more values, points start to go anywhere, but not where they belong.
That is the code I've used:
\addplot[only marks, mark = diamond, color = orange, mark size = 3pt]
table[x=x1, y=data1]{example.dat};
\addlegendentry{data1};
\addplot[only marks, mark = square, color = gray, mark size = 3pt]
table[x=x2, y=data2]{example.dat};
\addlegendentry{data2};
\addplot[only marks, mark = o, color = blue, mark size = 3pt]
table[x=x1, y=data3]{example.dat};
\addlegendentry{data3};
And this is the graph I get:
Thanks a lot!
Btw. in the real data one data set is missing a x/y value in the middle of the data. I hope that doesn't matter compared to my example.
pgfplots is interpreting 2 tabs as a single separator. Thus, it sees the data file as:
x1 x2 data1 data2 data3
0 0 1 2 3
1 1 1 2 3
2 1 3
Solution 1. You can replace empty cells with NaN. pgfplots will interpret this correctly:
x1 x2 data1 data2 data3
0 0 1 2 3
1 1 1 2 3
2 nan 1 nan 3
Solution 2. Use another type of separator (e.g., semicolons or commas):
\begin{filecontents*}{example.csv}
x1;x2;data1;data2;data3
0;0;1;2;3
1;1;1;2;3
2;;1;;3
\end{filecontents*}
\pgfplotstableread[col sep = semicolon]{example.csv}\mydata
\begin{document}
...
Here I've included the data file in the TeX file, but it should also work with a separate data file.
I have arrayformula in the first row of a column so my values and calculations can start in Row 2 and for all the column length.
I have this situation:
https://docs.google.com/spreadsheets/d/11oDra7Vja4-5C0Uix7JTgLLSMG3gPj-6fkajXlWqqQk/edit?usp=sharing
I need a simply arithmetic operation:
Subtract above value of the same column for every row.
I'm using:
=arrayformula(IF(row(A:A)=1; "What I have now"; IF(ISBLANK(A:A); ""; A1:A-A2:A)))
but as you see is wrong.
How to do that?
UPDATED QUESTION:
And then in the second sheet I need a SUM operation with some blank cells in column:
How to do that?
https://docs.google.com/spreadsheets/d/11oDra7Vja4-5C0Uix7JTgLLSMG3gPj-6fkajXlWqqQk/edit#gid=931743679
If you want to have the array formula ion the header this is a bit weird as you need to allow the formula to technically access row 0, we can do this by constructing ranges.
=ArrayFormula(IF(
--(ROW(A1:A) > 2) + -ISBLANK(A1:A) = 1;
{0; A1:A} - {0; A2:A; 0};
""))
--(ROW(A1:A) > 2) + -ISBLANK(A1:A) = 1 Checks if the row is populated and not one of the first two rows in a way that works nicely with array formulas
{0; A1:A} - {0; A2:A; 0} does the following:
0 Data 156 123 110 95 42
- - - - - - -
0 156 123 110 95 42 0
= = = = = = =
0 33 13 15 53 42 42
N N Y Y Y Y N <- Is shown
^ ^ ^
| | Because Row is blank
| |
Because row not > 2, thus it is never evalauated even though the second would cause an error
I think this is quite tricky. The problem is that in an array formula the number of cells in each array must match - you can't mix an array starting in row 1 with an array starting in row 2 if they go all the way to the bottom of the spreadsheet.
Here is one way of getting the result you want
=arrayformula({"What I need";"";offset($A$1,1,0,count(A:A)-1)-offset($A$1,2,0,count(A:A)-1)})
You will need to change the ; and , for your locale.
I have built up an array using the {} notation to define the elements. In my locale a ; means go to the next row, so I have defined the first two cells directly as strings. After that I've chosen to use Offset to get the range A2:A5 (1 row down from A1, 0 rows across and 4 cells high) and subtract the range A3:A6 (2 rows down from A1, 0 rows across and 4 cells high) it so that gives me the other 4 cells.
B1 "What I need"
B2 ""
B3 A3-A2=33
B4 A4-A3=13
B5 A5-A4=15
B6 A6-A5=53
but will need an IF statement adding if there are any blank cells between the numbers.
In the particular case of your updated question where there are fewer numbers in column D than column C, the formula would be
=arrayformula({"Special Case";"";offset($D$1,1,0,count(D:D))+offset($C$1,2,0,count(D:D))})
But in the general case of there being blank cells anywhere, you would have to test everything
=arrayformula({"General Case";"";if(offset($D$1,1,0,rows(C:C)-2)="","",if(offset($C$1,2,0,Rows(C:C)-2)="","",offset($D$1,1,0,rows(C:C)-2)+offset($C$1,2,0,Rows(C:C)-2)))})
for example my cell contains T 6.5 I want to look for all cells in a row that contain T and add the values of the numbers also contained in that cell.
If you don't mind a row beneath your data to help total things, I would suggest using the following as a quick solution.
Assuming that your data is in Row 1 (starting in cell A1), insert the below formula in Row 2 (cell A2) and copy it to the right as far as you have data in Row 1.
=IF(IFERROR(SEARCH("T ",A1),0)<>0,VALUE(SUBSTITUTE(A1,"T ","")),0)
From there you can total the values across Row 2 using this:
=SUM(2:2)
Note that I assumed that there was a space after "T" in your example above and that this is explicitly included in the first formula above. It simply strips that text from the cell and adds up the remaining numerical value IF the cells in Row 1 have a "T " in them.
Hope this helps or points you in the right direction.
Cheers!
Here is an example for row #7
Sub SumARow()
Dim roww As Long, r As Range, _
Zum As Double, v As Variant
roww = 7
For Each r In Cells(roww, 1).EntireRow.Cells
v = CStr(r.Value)
If InStr(1, v, "T") > 0 Then
Zum = Zum + GetNumber(v)
End If
Next r
MsgBox Zum
End Sub
Public Function GetNumber(s As Variant) As Double
Dim msg As String, i As Long
GetNumber = 0
msg = ""
For i = 1 To Len(s)
ch = Mid(s, i, 1)
If ch Like "[0-9]" Or ch = "." Then
msg = msg & ch
End If
Next i
If msg = "" Then Exit Function
GetNumber = CDbl(msg)
End Function