How can I take the value from the above cell, and get an array of it until it meets a non-empty cell.
All must happen in the same column
Example:
Column A
INPUT (any value)
copy of A1
copy of A1
copy of A1 (the array stops here, because next cell isn't empty)
ANOTHER VALUE
The array should stop without the "overwrite data" error
possible, but you cant jump over existing values so you need a formula in A2, A6, etc...
another solution would be: https://stackoverflow.com/a/69140434/5632629
Related
How can I write an IFF function in Informatica for the attached sample data. I have a target table which consist of different columns. I currently have different expressions like.
IIF(LTRIM(RTRIM(SUBSTR(HEADER_INFO,1,1)))='',NULL,LTRIM(RTRIM(SUBSTR(HEADER_INFO,1,1))))
IIF(LTRIM(RTRIM(SUBSTR(DETAIL_INFO,2,4)))='',NULL,LTRIM(RTRIM(SUBSTR(DETAIL_INFO,2,4))))
The first expression above picks up H from the first row below and assigns it to a column A, there is another expression function which assigns P to another column B, it continues until it reaches the last character on the first row and assigns it to a column P.
The second IFF function above reads 1 and assign it to a column W, then similar expression with different position assings P to a certain column X,another assins 009046678402 to column Y, then another assigns 40 to Z.
What i want to achieve is that, after reading and assigning values on the second row, if the next row after that starts with a 'D' again, it should still read it. But the current IFF function I have, only reads if there is rows alternate as
HP...
D1...
where as I want that if there is a scenario as shown in the attachment where you have
HP...
D1...
D2...
D3...
it should still read the and assign values ofenter image description here D1..., D2..., D3...
HP2519263013900HWA8365C DEFORD DONITA 1245327121 1184950479 2012516 0 201909202019092016 0
D1 P00904667840240
I resolved the issue by creating variable ports for each field and replacing the null in my TRIM with their respective variable ports like below IIF(LTRIM(RTRIM(SUBSTR(HEADER_INFO,1,1)))='',v_ID,LTRIM(RTRIM(SUBSTR(HEADER_INFO,1,1)))),
IIF(LTRIM(RTRIM(SUBSTR(HEADER_INFO,2,4)))='',v_LST_Name,LTRIM(RTRIM(SUBSTR(HEADER_INFO,2,4))))
I have a Google Sheet with many (many, many) cases of the following situation:
A B C D E
1 a b1 e1
2 a
3 b2 d e2
4 a e2
Basically each row lists content (information about research papers) scraped from a different location; theoretically, the values in each row should be the same, but since some locations lacked some information, and sometimes the information differs in some minor (but possibly important) way, there isn't 100% agreement throughout.
I'd like for each cell below such a group to display one value if all the non-empty values in that column are the same and to display nothing at all if there's some disparity between the non-empty values. See row 5 below:
A B C D E
1 a b1 e1
2 a
3 b2 d e2
4 a e2
5 a d
This is basically a first programmatical clean-up to assist further manual labor (which is unavoidable).
There's an example sheet available here - the real thing would have about 18 sets of values (title, authors, ISBN, publication, URL, keywords, etc), and 270 columns (each for another publication). The orange rows at the bottom are just pasted in manually but show the values I would like to get in the blue rows via formulas.
I realize this can be done with a massive string of IFs, but... surely there must be a way to write a formula that will extract all the non-empty values from an array or group of cells, compare them with each other, and return a single value if they're all equal?
Unfortunately, I'm drawing a blank...
=IFERROR(IF(COUNTA(UNIQUE(FILTER(B2:B5, B2:B5<>"", B2:B5<>"#N/A")))>1, ,
UNIQUE(FILTER(B2:B5, B2:B5<>"", B2:B5<>"#N/A"))))
or shorter:
=IF(COUNTUNIQUE(FILTER(D2:D5, D2:D5<>"", D2:D5<>"#N/A"))>1, ,
UNIQUE(FILTER(D2:D5, D2:D5<>"", D2:D5<>"#N/A")))
Countunique should work:
=if(countunique(A1:A4)=1,sortn(A1:A4,1),"")
I've used sortn because I want to remove any empty cells from the list of values before displaying what should be the single non-empty value and that is one way of doing it (empty cells are sorted to the end so won't appear).
Edit
If the data includes #N/A's probably the shortest way to deal with them would be to use the (to me slightly obscure) function countuniqueifs
=if(countuniqueifs(A1:A4,A1:A4,"<>#N/A")=1,sortn(A1:A4,1),"")
Blank cells and #N/A's are still sorted after everything else, so I think the sortn part should still be valid.
But there is a further issue with this - if the range contains empty strings returned from a formula, the sortn part won't work properly, so would have to fall back on filtering:
=if(countuniqueifs(C1:C4,C1:C4,"<>#N/A",C1:C4,"<>")=1,filter(C1:C4,C1:C4<>"#N/A",C1:C4<>""),"")
This is surely not an optimal solution but it works
=IF(COUNTIF(A1:A7,first_non_empty_cell)=COUNTA(A1:A7),first_non_empty_cell,"")
You might consider replacing first_non_empty_cell with
LOWER(INDEX(A1:A7,MATCH(1,INDEX((A1:A7<>0),0),0)))
or with the cell containing the value you want to use for comparisons.
I'm trying to apply a formula without having it add the formula data to each and every cell - in other words, I need the cells that are receiving the formula to be untouched until they get their data.
I was searching around and it looked like an ARRAYFORMULA would work but it doesn't seem to be doing anything when I apply it.
For example, I want to apply this formula to a cell range: =SPLIT(E2, ",")). Each cell in the E column needs to be split into two the two adjacent cells next to it based on it's comma. When I try to apply =ARRAYFORMULA(SPLIT(E2:E99, ",")) only the cell I add this to gets the formula.
In addition to the contribution of pnuts, also try:
=ArrayFormula(iferror(REGEXEXTRACT(","&E2:E,"^"&REPT(",+[^,]+",COLUMN(OFFSET(A1,,,1,6))-1)&",+([^,]+)")))
Note: the last parameter of OFFSET can be changed to match the maximum number of values you have in the cells of the range E2:E (separated by a comma). E.g: if you have a no more than 3 values per cell, set it to three. The output will then be three columns wide (one column for each value).
Hope that makes sense ?
Also credits due to AdamL who (I believe) orginally crafted this workaround.
I think what you want may be array_constrain but for your example I can only at present offer you two formulae (one for each side of the comma):
=Array_constrain(arrayformula(left(E2:E,find(",",E2:E)-1)),match("xxx",E:E)-1,1)
=Array_constrain(arrayformula(mid(E2:E,find(",",E2:E)+1,len(E2:E))),match("xxx",E:E)-1,1)
When bringing in data into excel via whatever method (import, paste, ...) I sometimes get the following issue. At the beginning of the cell there is an extra space in front of the text. Now I know the usual procedures to handle this namely:
trim(cell number)
and if its not a space character
=TRIM(SUBSTITUTE(cell number,CHAR(160),CHAR(32)))
But this time both of these didn't work. I did try other substitute CHAR's.
AND the character at the beginning is just plain weird. When I go to the very beginning of the cell and try to delete it I must hit the delete key twice to remove one space! But when I go to the first character in the cell and instead hit backspace I only need to press it once.
What else can I do to eliminate this weird non-space whitespace character?
If cell A1 contains non-visible junk characters, you must identify them before you can remove them.
Pick some cell and enter:
=IFERROR(CODE(MID($A$1,ROWS($1:1),1)),"")
and copy down. This will give you the CHAR code for each character in A1
Then you can use SUBSTITUTE() to remove the offender.
Lets assume column A has text where some cells are good and some have text with the weird space like character at the front. So some cells we want to change and some we don't.
1) Create a one column table with one letter in each cell. I decided to go over to the right to column H for the table. So for example cell H1 has A, cell H2 has B and so on.
2) Get the length of the cell we want to edit. I've put this formula in cell B1.
=LEN(A1)
3) Test the cell for the first letter. This gives us which cell to change and which not. I've put this formula in cell C1.
=ISNA(VLOOKUP(LEFT(A1),$H$1:$H$26,1,0))
4) Change (or not depending on step 3) using RIGHT and the result from LEN.
=IF(B1,RIGHT(A1,B1-2),A1)
Notice that I have to subtract 2 spaces and not one? Like I said it was a strange character.
5) Repeat down the column.
If the first legitimate character in your string will be in the set [A-Za-z0-9] then you could use this formula:
=MID(A1,MIN(SEARCH({"a";"b";"c";"d";"e";"f";"g";"h";"i";"j";"k";"l";"m";"n";"o";"p";"q";"r";"s";"t";"u";"v";"w";"x";"y";"z";0;1;2;3;4;5;6;7;8;9},A1&"abcdefghijklmnopqrstuvwxyz1234567890")),99)
where 99 is longer than the longest string might be. If there are other legitimate starting characters, then add them to both the array constant and the string at the end.
If you might need to remove trailing spaces (char(32)), you can enclose the above in a TRIM function.
I want to store the string in array values with specified position.
For example:
The letter "A" is stored in 3rd position in an array(CCArray). No values in other position.
I am trying the following code
world->insertObject(character,2); //character is CCString
The above method is pushed the existing values to next place. I want to over write the existing one.
The new character is stored in second place. There is no need old value.
Can any one assist me?
The above logic have the following coding
word->removeObjectAtIndex(4);
word->insertObject(character,4);
First remove the string and then insert the CCString.
Now it works fine.