How can i add .JPG at end of all the serial number (001,002,003).
C:\Users\Abc\Desktop\id card 10-12-19\001.jpg
C:\Users\Abc\Desktop\id card 10-12-19\002.jpg
Is there any way to add the extension at the end (.jpg), I would suggest how it work in both i.e Microsoft Excel and Google spreed sheet. Any suggestion or help. Thanks
try like:
=ARRAYFORMULA(IF(A1:A="";;A1:A&".jpg"))
=query(arrayformula(B21:B &".jpg"), "Select * where Col1<>'.jpg'")
in this formula I use query and array formula, and I put the formula in C21, the data populated in range all in column B begin from B21.
= arrayformula(B21:B &".jpg")
mean all row in column B begin from B21 will be given by ".jpg"
=query(arrayformula(B21:B &".jpg"), "Select * where Col1<>'.jpg'")
Only return from resul of array formula, just if in column B have string (not blank)
Related
Hi everyone,
I have 2 tables, 3rd column for Table 1 is Value 1 and 3rd column for Table 2 is Value 2. I combined these 2 tables by expanding both tables first so that all the columns are aligned as shown in the screenshot above (Column E to Column H).
The formula in all the yellow cells are:
Cell E4 : =QUERY(A4:C10,"Select A,B,C,' ' label ' ' 'Value 2' ")
Cell E12 : =QUERY(A12:C20,"Select A,B,' ',C label ' ' 'Value 1' ")
Cell K7 : =QUERY({E5:H10;E13:H17},"Select * where Col1 is not null",0)
Cell P7 : =ArrayFormula(IF(ISBLANK(M7:M12),100,M7:M12))
In column P, I want to return 100 as Value 1 if the cells in Column M is blank. So by right I should get 2,34,55,100,100,100 in column P but right now the formula still return 3 blank cells.
I suspect that is because the QUERY function that I used before which make the cell is not blank although it seems like still a blank cell. May I know is there any trick that I can use to find the blank cells in column M and column N (preferably don't touch the QUERY formula) since ISBLANK() is not working in this case?
Any help or advise will be greatly appreciated!
Edited
makes sense. you cant use ISBLANK because cell is not blank. remember that QUERY inserted an empty space.
try:
=ARRAYFORMULA(IF(ISBLANK(TRIM(M7:M12)), 100, M7:M12))
ISBLANK is so sensitive that it will detect even residue from TRIM
update:
=ARRAYFORMULA(IF(TRIM(M7:M12)="", 100, M7:M12))
I have 2 sheets like this :
In that 2nd sheet, i want to lookup the id (S/M/L/XL) by checking if value is in between the Min value and Max value. So the goal is to have something like that 2nd sheet where in 'level' column, i need to put a formula so it will check the value is between what range so then it will retrieve the correct 'id' from 1st sheet.
the rule is if the value is >= minvalue and < max value
How can i do this ?
Thanks
use:
=INDEX(IF(A9:A="",,VLOOKUP(A9:A, {C2:C5, A2:A5}, 2, 1)))
Your first table, has overlapping values, so I suggest you think better about the rules you want to apply.
For example, 1, according your table can match both "S" and "M" , same for 3, which can be "M" or "L".
Once you have resolved that, you can use the QUERY function.
Example:
=QUERY($A$2:$D$5,
"select A,D where C<="&A2&" AND D >="&A2&" ORDER BY D DESC LIMIT 1 ")
Working solution can be found here:
https://docs.google.com/spreadsheets/d/1oLVwQqihT_df2y_ZQnfx7By77HnKSFz0bcbOzMuWqOM/edit?usp=sharing
Rather than have min and max columns, you could just use one column to list incremental values that determine the next size, and use vlookup() with a sort option of true - this avoids overlapping values:
=arrayformula({"level";if(A2:A<>"",VLOOKUP(A2:A,{Source!C:C,Source!A:A},2,1),)})
can someone help me in replacing periods with forwarding slashes in sheets?
I have a data set with over 100 thousand rows in sheets,
I have a date-time formatted as such D.M.Y I need to change it to D/M/Y
each row has 7 or so columns based on date-time.
anyways, below is the first 6 rows of column 'A'
so its format is D.M.Y
so I have 100,000 rows of this in column 'A'
Date
21.06.2019
22.06.2019
23.06.2019
24.06.2019
25.06.2019
26.06.2019
I want to turn it into this
Date
21/06/2019
22/06/2019
23/06/2019
24/06/2019
25/06/2019
26/06/2019
I need it in this format as sheet does not recognize the '.' as a separator and it would take an eternity to do it manually, thanks!
A link to my screen below to see the format
check if your dates are valid dates with:
=ISDATE(A2)
if yes use this in B2:
=ARRAYFORMULA(TEXT(A2:A; "dd/mm/yyyy"))
if no you can use:
=ARRAYFORMULA(SUBSTITUTE(A2:A; "."; "/"))
and if you need real dates do:
=ARRAYFORMULA(QUERY(IFERROR(DATEVALUE(SUBSTITUTE(A2:A; "."; "/")));
"format(Col1) 'dd/mm/yyyy'"))
Assuming your data is on Sheet1 in columns A through G.
On a blank tab, say Sheet2, in cell A1, you could use this formula to substitute the . with /.
=ARRAYFORMULA(SUBSTITUTE(Sheet1!A:G,".","/"))
This should give you the substituted values. You could then copy these and paste them as values to Sheet1.
if you want to use macro or script do like this:
function ReplaceDotToSlash()
{
var sheet = SpreadsheetApp.getActive().getSheetByName('YourSheetName');
var lastRow = sheet.getLastRow();
for (var i = 1; i < lastRow+1; i++){
var value1 = sheet.getRange('A'+i).getValue() + "";
sheet.getRange('A'+i).setValue(value1.replace(/\./g, "/"));
}
}
I have a database that I am reading with sqlite3 in Python 2.7, using the following command:
# Change to database directory
os.chdir(data)
# Find database file
cur_db = glob.glob('*.db')
# Connect to database
con = sqlite3.connect('database.db')
c = con.cursor()
# Query database
print(len(available_table))
for row in c.execute('SELECT * FROM col1 '):
print row
which gives me something like:
(1, u'2.3', u'brown', u'0', u'hairy', u'banana', u'2', u'monkey')
I would like to look at values in the column w/ the value u'2.3' greater than 2. But this is a unicode string instead of a number, making it difficult to compare to a number (eg 2).
Ideally, I would like something like:
# Connect to database
con = sqlite3.connect('database.db')
c = con.cursor()
# Query database
c.execute('SELECT * FROM critter WHERE weight > 2'.
QUESTION: How can I add a conditional statement to extract only data rows where this element is greater than 2? I would like to leave the database unaltered.
Edit: oh you want a query to do that... You can do:
for row in c.execute('select * from critter where cast(weight as numeric) > 2'):
# do something
Older answer:
If you want to do this on the Python side you can use a try-except construct like so:
for row in c.execute('SELECT * FROM col1'):
try:
val = float(row[1]) # number here is the number of the element in the tuple
if val > 2:
print(val)
except ValueError:
pass
My model takes two numbers from one sheet, adds the average to another sheet in the last cell of a defined column. The problem that I have is that when I insert a new column, the references get missed up and I'm trying to have a macro that would 1. take the average 2. look for a specific column on the second sheet 3. paste the averaged value to the last cell.
Please help me with this I have been trying to get my head around it for a long time.
my problem is that I have to insert new columns and I need to keep the references dynamic when adding a value to the last empty cell in a column. For example: if i have salary as col A, and expenses as Col B - in this model that I have now I put in .Cells(emptyRow, 1) and .Cells(emptyRow, 2) now if I insert a column between A and B the references 1 and 2 will not work. Is there anyway that I can work around this where if i add a new column it wont mess up the references in the macro?
Thank you.
This is the code that I have right now but it does not really work - when I insert a new column the column defined name does not shift right.
Sub demo()
Dim expCol As Long, FirstEmptyRow As Long
Range("B:B").Cells.Name = "expenses"
expCol = Range("expenses").Column
FirstEmptyRow = Cells(Rows.Count, expCol).End(xlUp).Row + 1
Cells(FirstEmptyRow, expCol).Value = 123
End Sub
P.S. 123 here is just an example for testing purposes. The value that would replace it in my model is the average I talk about in the question.
If your columns have headers (I guess they do), and your data has no gaps just use
Range("1:1").Find(columnName).End(xlDown).Offset(1,0) = 123
If a column can have just a header but no values, you need to add additional check if second row isn't empty.
If you create a named range this way (rather than the Range.Cells.Name way you were using), then when inserting columns the reference will be dynamic. Now if you insert columns between A and B later in the code, you can still use expCol and FirstEmptyRow to reference the first empty cell in the expenses column, where ever it may have moved to on the sheet, as long as you update them after each column insertion.
Sub Demo()
Dim expensesrng As Range
Dim Expenses As Range
Dim expCol As Long
Dim Exprng As Range
Dim FirstEmptyRow As Long
'set the original range to use for the expense column
Set expensesrng = Range(Range("B1"), Range("B1").End(xlDown))
'add the named range
ActiveWorkbook.Names.Add Name:="Expenses", RefersTo:=expensesrng
' create a variable to refer to the Expenses Range
Set Exprng = ActiveWorkbook.Names("Expenses").RefersToRange
expCol = ActiveWorkbook.Names("Expenses").RefersToRange.Column
FirstEmptyRow = Exprng.End(xlDown).Offset(1, 0).Row
Cells(FirstEmptyRow, expCol).Value = 123
'after inserting columns then you will have to get/update the column number
'of the expense named range and the first empty row before adding your new expense
'data to it
Range("B:B").Insert Shift:=xlShiftToRight
expCol = ActiveWorkbook.Names("Expenses").RefersToRange.Column
FirstEmptyRow = expensesrng.End(xlDown).Offset(1, 0).Row
Cells(FirstEmptyRow, expCol).Value = 123
End Sub