How do I merge cells of the same column in LyX? - layout

I have 3 subfigures I want to arrange so that 1 will be in the left and 2 will be in the right (one above the other):
Figure 1 | Figure 2
Figure 1 | Figure 3
Figure 1 should appear only once of course - across the entire column.
I thought I should use 2x2 table to arrange them, but I can't find a way to merge the two cells in the same column to one cell in order to put figure 1 there.
How can I merge the two cells in the same column?

You want to use the multirow package. Add the package, and use something like this:
\begin{tabular}{l|l}
\multirow{2}{*}{<figure 1>} & <figure 2> \\
& <figure 3>
\end{tabular}

You can enter Latex code snippets directly in Lyx using "Insert TeX code", bound to ALT-L by default.
So:
Add \usepackage{multirow} to your preamble (using the Document/Settings... menu item);
Insert the Latex code b0lt recommended.
multirow is part of the basic Texlive install, so you shouldn't need to import it.

Related

Using UNIQUE with non-adjecent columns on different sheets

I have two tables on two sheets - let's say tblFruits1 and tblFruits2.
Both have a column "Name".
Apple - for example - exists on both lists.
The lists might have a different number of rows
tblFruits1 on Sheet1
Name
Color
Apple
red
Peach
yellow
Ananas
yellow
tblFruits2 on Sheet2
Name
Color
Apple
red
Cherries
red
Banana
yellow
Melone
green
Now I would like to get - on a third sheet - a UNIQUE list of names of both tables.
expected result on Sheet3
Name
Apple
Peach
Ananas
Cherries
Banana
Melone
=UNION((tblFruits1[Name],tblFruits2[Name])) returns an error.
I tried variants with SEQUENCE and INDEX but didn't succeed.
So the question is:
How can I "construct" the matrix-parameter for UNIQUE from two column-ranges on two different sheets?
(What I am looking for is a non-VBA-solution - I know how to handle this in VBA.)
The VSTACK function makes the Union obsolete (only available to insiders at time of writing)
Since finding the Union of several ranges is a quite usefull function on its own, I use a LAMBDA to do that. The output of that can then be passed to UNIQUE
The Lambda, which I call, unimaginatively, UNION
=LAMBDA(tabl1, tabl2,
LET(rowindex, SEQUENCE(ROWS(tabl1)+ROWS(tabl2)),
colindex, SEQUENCE(1,COLUMNS(tabl1)),
IF(rowindex<=ROWS(tabl1),
INDEX(tabl1,rowindex,colindex),
INDEX(tabl2,rowindex-ROWS(tabl1),colindex)
)
)
)
Then
=UNIQUE(Union(tblFruits1[Name],tblFruits2[Name]))
gives the result you seek
Try:
=LET(X,CHOOSE({1,2},tblFruits1[Name],tblFruits2[Name]),Y,COUNTA(X),Z,MOD(SEQUENCE(Y)-1,Y/2)+1,A,INDEX(X,Z,CEILING(SEQUENCE(Y)/(Y/2),1)),UNIQUE(FILTER(A,NOT(ISNA(A)))))
This is a solution I created where you can replace a2# and c2# with any two arrays, dynamic arrays, etc. It also deduplicates and sorts it. This works on Excel for Mac (FILTERXML is not supported)
=LET(
firstArray, a2#,
secondArray, c2#,
totalCount, COUNTA(firstArray)+COUNTA(secondArray),
firstCount, COUNTA(firstArray),
SORT(UNIQUE(MAKEARRAY(totalCount,1,LAMBDA(r,c,IF(r<=firstCount,INDEX(firstArray,r),INDEX(secondArray,r-firstCount+1))))))
)
Can you try like this and make your Sheet1 data and Sheet2 data into Table
an in your Sheet3 cell A2 copy paste the formula below
=UNIQUE(FILTERXML(""&TEXTJOIN("",1,(IFNA(IF({0,1},Table1[Name],Table2[Name]),"")))&"","//b"),FALSE,FALSE)
There is a new function that simplifies this: VSTACK
For a unique (distinct) union (as per the original question), try this:
=UNIQUE((tblFruits1[Name],tblFruits2[Name]))
And to sort them:
=SORT(UNIQUE((tblFruits1[Name],tblFruits2[Name])))
I don't have VSTACK or HSTACK at this point (or LAMDA either), unless I resort to keeping workbooks on slow-and-clunky Excel Online. But say you have 3 dynamic arrays (named three, four and five), each with 2 columns and a variable number of rows. Then (to keep things readable) use a named formula combo defined as =SEQUENCE(ROWS(three)+ROWS(four)+ROWS(five)). Then this works:
=IFS(
combo<=ROWS(three), three,
combo<=ROWS(three)+ROWS(four), INDEX(four,combo-ROWS(three),{1,2}),
TRUE, INDEX(five,combo-ROWS(three)-ROWS(four),{1,2})
)
You can wrap UNIQUE and/or SORT around this, if you like. If the arrays have 3 columns rather than 2 then use {1,2,3} in the formula.
Obviously you can expand this to more than 3 arrays by building more conditions into the IFS formula.
Perhaps it's worth noting that three is the same thing as INDEX(three,combo,{1,2}). And using COLUMN(three) would make the syntax more generalisable, though it doesn't allow you to re-order the columns if you want something like {2,1,3} in your output. Also, TRUE is effectively how you say "ELSE" in an IFS formula--it's a bit more concise here than combo<=ROWS(three)+ROWS(four)+ROWS(five). Using these longer forms would make the formula more symmetrical but a lot wordier!
(It would be nice if VSTACK ever becomes available on the desktop.)

How can I get Excel to show me if the same values are appearing, even though they are not in the same order

Basically what I have is a 3 columns of data with a 4th that is a CONCENTATE of the three columns, however, the data repeats sometimes in a diffeent order and i need to either highlight or show with a 0 or 1 if the same values have been repeated in a different order, the image attached shows what I would want to happen
Can Anyone help as i'm banging my head on the desk here
If you have O365 with the SORT function, you can set up a helper column:
=CONCAT(SORT(A1:C1,,,TRUE))
Then use conditional formatting to check for duplicates.
If you don't have the SORT function, you can try:
=CONCAT(INDEX(A1:C1,N(IF(1,COUNTIF(A1:C1,"<" & A1:C1)+1))))
and if you don't have the CONCAT function, try:
=INDEX(A1:C1, INDEX(COUNTIF(A1:C1,"<"&A1:C1)+1,1)) & INDEX(A1:C1,INDEX(COUNTIF(A1:C1,"<"&A1:C1)+1,2))&INDEX(A1:C1,INDEX(COUNTIF(A1:C1,"<"&A1:C1)+1,3))

Excel: Multiple Substitute without nesting and without VBA

I have cells that have data that I want to remove. The cells typically look like this:
alm1 105430_65042M
1993_5689IB
ALM99 3455 344C
0001_4555Alm5
Some but not all of the cells contain text like "almj" where "j" is a positive integer. I want to remove that part. I want the output to look like this:
105430_65042M
1993_5689IB
3455 344C
0001_4555
So something like this works
SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"alm1",""),"ALM99",""),"Alm5","")
But for my full data set I would need this to be several-hundred-deep nested function because my "alm" is sometimes in capital letters and sometimes not and the integer can vary from 1 to 100. This seems like a painful way to do this.
Is there a way that I can tell it to look for text listed in a column (so I can have a column in a different sheet that just goes from alm, alm1, ..., alm100 ) and then also ask it to ignore capitalization and then just replace stuff?
I tried referencing a column $M$1:$M$100 in the second argument of the function substitute but it's not working.
SUBSTITUTE(A2,$M$1:$M$100,"")
Where the column M contains "alm" alm1", ..., "alm100" etc.
This should work for you, it returned expected results on your provided sample data:
=IF(COUNTIF(A2,"*alm*")=0,A2,TRIM(SUBSTITUTE(A2&" ",MID(A2&" ",SEARCH("alm",A2),FIND(" ",A2&" ",SEARCH("alm",A2))),"")))
Excel has lousy string-handling capabilities. Regular expressions would make this task much easier.
In JavaScript, it's as simple as:
string.replace(/ *alm[0-9]+ */gi,'')
This does a global (g) case-insensitive (i) search of everything with:
0 or more spaces
followed by "alm" (in any case)
followed by 1 or more numbers
followed by 0 or more spaces
You can paste your data in the HTML box in this fiddle, and it will fix it:
http://jsfiddle.net/xs71bvan/2/

Horizontal reference not working in excel

Below there are two pictures of tables
vertical table is Temp data 2014.xlsm
horizontal table is Overview_allcities 2014.xlsm
I want to quickly setup the values in the horizontal table using the auto fill.
The value of C34 in the horizontal table is
=IFERROR(IF(MATCH('[Temp data 2014.xlsm]Harrison'!$A$2,A1,0)=1,'[Temp data 2014.xlsm]Harrison'!$D$4,""),"--")
Now when I drag it to the right I want to increment it to "$D$5" i.e.
=IFERROR(IF(MATCH('[Temp data 2014.xlsm]Harrison'!$A$2,A1,0)=1,'[Temp data 2014.xlsm]Harrison'!$D$5,""),"--")
I tried using changing the references to absolute and relative. None would do this step automatically.
Not-so out of the box idea here. Have your tried doing it with INDIRECT() ?
In my head I'm thinking something like this in the horizontal table:
You could use COLUMN() to create a moving variable. You in this case C34 - B would be 1, then +3 offset to get 4. Merge those together into a text string and you'd get a $D$4, then $D$5, and so on.
"'[Temp data 2014.xlsm]Harrison'!$D$" & COLUMN() - COLUMN($B:$B) + 3
Then implement it into the formula using INDIRECT().
=IFERROR(IF(MATCH('[Temp data 2014.xlsm]Harrison'!$A$2,A1,0)=1,INDIRECT("'[Temp data 2014.xlsm]Harrison'!$D$" & COLUMN() - COLUMN($B:$B) + 3),""),"--")
Now, I'm 100% grasping at straws here since I've only quickly tested this but I'm quite certain it could prove useful.
Let me know if it works, or not. Might have to work out a few kinks!

Excel Advanced filtering multiple columns with multiple acceptable data combinations

I have a large data set with 4 columns of interest all containing text, namely pokemon moves. The columns "move 1" through to "Move 4" each contain a different move, and each row differs in the combination.
eg.
" A | B | C | D | E".
" 1 Pokemon | Move 1 | Move 2 | Move 3 | Move 4".
" 2 Igglybuff | Tackle | Tailwhip | Sing | Attract".
" 3 Wooper | Growl | Tackle | Rain Dance| Dig".
~ 1000 more
My issue is this:
I wish to filter this data set for rows (pokemon) containing a certain combination of moves from a list.
eg. I want to find which pokemon have both "Growl" and "Tackle". These moves can appear in any of Moves 1 to 4 (aka order of the moves is unimportant)
How would I go about filtering for such a result. I have similar situations in which I would want to search for a combination of 3 or 4 moves, the specific order of which is not important, or also search for specific pokemon possessing a specific combination of moves.
I've attempted to use functions such as COUNTIF without avail.
Help / Ideas are much appreciated
There are a number of options for advanced filtering in excel that you might consider:
Option 1 - Advanced Filters
Advanced filters give you the power to query over multiple criteria (which is what you need). You can also easily do it as many times as you want to generate the final datasets using each filter. Here is a link to the advanced filter section for Microsoft Excel 2010, which is virtually identical here to 2007. It would be a great place to start if you want to move outside of just using basic formulas.
If you do go down this route, then follow the directions on the site in terms of steps:
Insert the various criteria that you have selected in the top rows in your spreadsheet and specify those rows in the list range
Set the criteria range to the place holding all your data on a single worksheet
Run the filter and look at the resulting data. You can easily do a count on the number of records in that reduced data set.
Option 2 - Pivot Tables
Another option that you might look at here would be to use Pivot tables. Pivot tables and pivot charts are just phenomenal tools that I use in the workplace every day to accomplish exactly what you are looking for.
Option 3 - Using Visual Basic
As a third option, you could try using visual basic code to write a solution. This would give you perfect control as you could specify exactly the ranges to look at for each of the conditions. Unfortunately, you would need to understand VB code in order to use this solution. There are some excellent online resources available that can help with this.
=COUNT(INDEX(MATCH(B2:E2, MoveList, 0), 0)) > 0
will return TRUE if any of the values in the range B2:E2 (Moves 1 through 4) are in the range defined by Move List. You want to use a named range so that you can easily copy this formula down for all of your thousand rows.
If you remove the last part that checks whether the COUNT() value is greater than zero, you get:
=COUNT(INDEX(MATCH(B2:E2, MoveList, 0), 0))
which will return the number of moves that the Pokemon has that match a move on the move list.
MATCH() takes three arguments: a lookup value, the lookup range, and the match type. I don't fully understand why, but wrapping that part of the formula in INDEX() seems to let you use an array for the first argument. Maybe someone here can provide a better explanation.
In any case, the formulae above do appear to solve the problem.
Finally, if you're only checking for a few moves, instead of using a confusing formula and a named range as above, you could just make a column for each move that you want to check for, e.g. "Has Growl?" and "Has Tackle?". You would then just use =COUNTIF(B2:E2, "Tackle") and =COUNTIF(B2:E2, "Growl"). You could then make another column that sums these columns and filter out the zero values to display only Pokemon who have Tackle or Growl.
I looked at these two pages when researching how to accomplish this:
https://www.excelforum.com/excel-general/786407-find-if-any-value-on-one-list-exists-on-another.html
https://www.deskbright.com/excel/using-index-match/

Resources