IF Column F = TEXT THEN change Column G - excel

I'm sure this is very simple but I'm having a difficult time getting it right.
Basically, if Column F is equal to a text string, then Column G should show another text string.

In your cell in column G:
=IF(F1="some_value","text_to_display","nothing?")

Assuming your data is like this:
Col F Col G
1 Black
2 White
3 Black
4
5 White
Your formula in Col G should be something like:
=IF(F1 = "Black", "Yes", IF(F1 = "White", "No", If(F1 = "", "", "")))
Using this formula would give you:
Col F Col G
1 Black Yes
2 White No
3 Black Yes
4
5 White No

Related

Can I use SUMPRODUCT to accomplish this?

Need to sum a range based on if a value is in a column and one of a set of values is in another column, or vice versa.
e.g. I have The following table:
A B C D
M C C 1
F C C 2
S N C 3
S N N 4
M - C 5
N C C 6
M C N 7
If (Column A contains "M" or "S") AND ((Column B contains "C" AND Column C Contains "C" Or "N" Or "-") OR (Column C contains "C" AND Column B Contains "C" Or "N" Or "-")) Then Sum column D
So from my table my results would be
1 + 3 + 5 + 7 = 16
You can use SUMPRODUCT like this:
=SUMPRODUCT(ISNUMBER(MATCH(A2:A10,{"M","S"},0)*MATCH(B2:B10&"^"&C2:C10,{"C^C","C^N","C^-","N^C","-^C"},0))+0,D2:D10)
MATCH is used to check for both valid possibilities in column A and then all 5 possibilities for concatenated columns B and C - if those conditions are met then column D will be summed. Extend column ranges as required but preferably don't use whole columns
.....or shorter with SUMIFS like this:
=SUM(SUMIFS(D:D,A:A,{"M";"S"},B:B,{"C","C","C","N","-"},C:C,{"C","N","-","C","C"}))
For that version you can use whole columns with no loss of efficiency.
Note that in this version all the separators in the array constants are commas EXCEPT for the semi-colon in {"M";"S"} which needs to be that way
I would add a fifth column with a condition for the current line returning the value in D if all conditions are true or 0 otherwise.
=Iif(AND(Or($A1 = "M", $A1 = "S"),OR(AND($B1 = "C",Or($C1 = "C",$C1 = "N",$C1 = "-")), AND($C1 = "C",OR($B1 = "C",$B1 = "N",$B1 = "-")))),$D1,0)
Then in a cell somewhere write =sum($E:$E). With your example, I get 16, as intended.

Count nonempty cells in column, if row contains word

This is what I have now:
=COUNTA(FILTER(A14:O,SEARCH($A$4,A14:A),SEARCH("*",F14:F)))/2
Looks something like this
A B C D E F [...]
14 word1 a h X
15 word2 c k X
16 word3
17
18 word1 c
19 word2 a j X
20 word3 b X
[...]
What I want it to do:
Basically I want to know how many cells in column F aren't empty but only count those where the row contains word1 in column A
What it does:
If column F is empty it returns 0.5, when it's supposed to be 0
If column F has X in row 18 but not 14 it returns 1, as it's supposed to
If column F has X in row 14 but not 18 it returns 6, when it's supposed to be 1
If column F has X in both row 14 and 18 it returns 7, when it's supposed to be 2
If column F has X in any row but 14 it returns the amount of Xs, as it's supposed to
I feel like I'm making this sound more complicated than it actually is.
=COUNTIFS(A1:A7,"word1",F1:F7, "*")
SYNTAX : COUNTIFS
Assuming the list of words is in Column A and Column F contains whatever, you could use:
=SUMPRODUCT((A1:A7="word1")*(F1:F7>0))
You are picking up a lot of extra counts from columns B:E (some of which seem to be zero-length strings and look like empty cells, but still register).
Try
=COUNTA(FILTER({A14:A,F14:F},SEARCH($A$4,A14:A),SEARCH("*",F14:F)))/2

Join/Concatinate column text based on criteria

I have a data set like this:
A B C
----------
1 A blue
1 A red
1 B blue
2 A red
3 B blue
3 B green
3 C blue
4 C blue
4 A blue
4 A green
And a separate table like this (this is already auto generated using UNIQUE()):
E F G
-----
1 A
1 B
2 A
3 B
3 C
4 C
4 A
I want to join text from column C and show the result in column G based on a criteria given in columns E and F. The result I am looking for would look like this (all concatenated/joined text should be in column G):
E F G
-----
1 A blue red
1 B blue
2 A red
3 B blue green
3 C blue
4 C blue
4 A blue green
Optional, not needed but would be nice: The delimiter between generated text is a line brake so each line is in a separate line inside the same row.
Thank you.
place your first table (data table/ 1,2,3) in column A to C.
and another table (5,6,7) in column E to G
Enter below Array Formula in G2
{=CONCAT(IF(A2:A11&B2:B11=E2&F2,C2:C11&" ",""))}
you will get your result.
For earlier versions, we need to create UDF
Function ConcatUDF(rng() As Variant, ByVal delim As String) As String
Dim a, i As Long
For i = 1 To UBound(rng, 1)
If rng(i, 1) <> "" Then
ConcatUDF = ConcatUDF & _
IIf(ConcatUDF = "", "", delim) & rng(i, 1)
End If
Next
End Function
and we will get the result.
Edited:
I forgot to absolute the references. Please consider below mnetioned formula.
with Build in CONCAT formula for excel 2016
=CONCAT(IF($A$2:$A$11&$B$2:$B$11=E2&F2,$C$2:$C$11&" ",""))
with UDF for earlier version of excel
=ConcatUDF(IF($B$2:$B$11&$A$2:$A$11=F2&E2,$C$2:$C$11,"")," ")

Nested SEARCH and IF grid

Column A lists the categories for individual products. Each product will have between 1 to 14 categories. The goal is to split all categories into separate cells (Columns B through O), to become easier to sort.
I've created formulas for columns B through O, to SEARCH for hyphens "-" and separate each category into its own column. Here's what the output should look like (except for the bottom row):
A B C D E F G ... O
Categories Cat 1 Cat 2 Cat 3 Cat 4 Cat 5 Cat 6 ... Cat 14
UX UX
CFT-WET CFT WET
WEM-US-CFT WEM US CFT
NC-US-CFT NC US CFT
TP-OB-SB-WEB TP OB SB WEB
DB-B-FC DB B FC
P-TP-SB-CP-DT P TP SB CP DT
DP-S-OB-WB-SB-FC DP S OB WB SB FC
P-TP-SB-CP-WEB-WS-S-TP-OB-C-CT-G-FC-MCB
I initially built these formulas:
Col B: =if(iserror(search("-",$A5)),$A5,search("-",$A5))
Col C: =if(iserror(search("-",$A5,sum(search("-",$A5)+1))),"",mid($A5,sum(search("-",$A5),1),sum(search("-",$A5,sum(search("-",$A5)+1)),-search("-",$A5),-1)))
Col D: =if(iserror(search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)),"",mid($A5,sum(search("-",$A5,search("-",$A5)+1),1),sum(search("-",$A5,search("-",$A5,search("-",$A5)+1)+1),-search("-",$A5,search("-",$A5)+1),-1)))
Col E: =if(iserror(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)),"",mid($A5,sum(search("-",$A5,search("-",$A5,search("-",$A5)+1)+1),1),sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1),-search("-",$A5,search("-",$A5,search("-",$A5)+1)+1),-1)))
Col F: =if(iserror(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)),"",mid($A5,sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1),1),sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1),-search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1),-1)))
Col G: =if(iserror(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)),"",mid($A5,sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1),1),sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1),-search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1),-1)))
Col H: =if(iserror(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)),"",mid($A5,sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1),1),sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1),-search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1),-1)))
Col I: =if(iserror(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)),"",mid($A5,sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1),1),sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1),-search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1),-1)))
Col J: =if(iserror(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)),"",mid($A5,sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1),1),sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1),-search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1),-1)))
Col K: =if(iserror(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)),"",mid($A5,sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1),1),sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1),-search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1),-1)))
Col L: =if(iserror(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)),"",mid($A5,sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1),1),sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1),-search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1),-1)))
Col M: =if(iserror(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)),"",mid($A5,sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1),1),sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1),-search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1),-1)))
Col N: =if(iserror(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)),"",mid($A5,sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1),1),sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1),-search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1),-1)))
Col O: =if(iserror(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)),"",mid($A5,sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1),1),sum(search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1),-search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1)+1),-1)))
...but these fail to recognize the final category for each row. Col B's formula has no problems, so I began to edit the formulas in Columns C to O:
Col C: =if(iserror(search("-",$A5,sum(search("-",$A5)+1))),if($B5<>"",right($A5,sum(len($A5),-search("-",$A5))),""),mid($A5,sum(search("-",$A5),1),sum(search("-",$A5,sum(search("-",$A5)+1)),-search("-",$A5),-1)))
Col D: =if(iserror(search("-",$A5,search("-",$A5,search("-",$A5)+1)+1)),if($C5<>"",if(iserror(search("-",$A5,search("-",$A5)+1)),"",right($A5,len(sum($A5,-search("-",$A5,search("-",$A5)+1))))),""),mid($A5,sum(search("-",$A5,search("-",$A5)+1),1),sum(search("-",$A5,search("-",$A5,search("-",$A5)+1)+1),-search("-",$A5,search("-",$A5)+1),-1)))
It appears this solution will work for all situations except when Column A has only one category. When that happens, a #VALUE! error will populate all columns to the right of Col B. How do I solve this?
For now, I'm stuck with this:
A B C D E F G ... O
Categories Cat 1 Cat 2 Cat 3 Cat 4 Cat 5 Cat 6 ... Cat 14
UX UX #VALUE! #VALUE! #VALUE! #VALUE! #VALUE! ... #VALUE!
CFT-WET CFT WET
WEM-US-CFT WEM US CFT
NC-US-CFT NC US CFT
TP-OB-SB-WEB TP OB SB WEB
DB-B-FC DB B FC
P-TP-SB-CP-DT P TP SB CP DT
DP-S-OB-WB-SB-FC DP S OB WB SB FC
P-TP-SB-CP-WEB-WS-S-TP-OB-C-CT-G-FC-MCB
Here's what I would use
I'm assuming row 1 of your spreadsheet contains "Cat 1", "Cat 2" etc. This formula relies on there being a space between "Cat" and the category number. I'm also assuming column A contains the concatenated string.
Note this requires that no category will ever have the character : in it. If there is a risk of this, you can modify the ":" to become any other character in the formula below (the below example goes in cell B2
=IF(LEN($A2)-LEN(SUBSTITUTE($A2,"-",""))+1>=VALUE(MID(B$1,SEARCH(" ",B$1)+1,100)), MID("-"&$A2&"-",SEARCH(":",SUBSTITUTE("-"&$A2&"-","-",":",VALUE(MID(B$1,SEARCH(" ",B$1)+1,100))))+1,SEARCH(":",SUBSTITUTE("-"&$A2&"-","-",":",VALUE(MID(B$1,SEARCH(" ",B$1)+1,100)+1)))-SEARCH(":",SUBSTITUTE("-"&$A2&"-","-",":",VALUE(MID(B$1,SEARCH(" ",B$1)+1,100))))-1),"")
A brief explanation: the last optional term of SUBSTITUTE is instance_num, which means you can change the nth instance of "-" to ":" and then search on that. This keeps the formula pretty simple. I've also added a "-" before and after the string in the formula to avoid having to use any if statements (there will always be a trailing and preceding "-")

excel data transposition using built in formulas

Heres the issue I have a dump from the database at work that is in a rather conveluted format. Basically it does not give you the displayed information as much as just the individual relation tables to work with.
EXAMPLE: lets say I have the following columns of information
ID, COLOR, SIZE, QTY, TYPE
the information looks something like this
ID COLOR SIZE QTY TYPE
A brown 20 1 1
C yellow 10 2 2
D brown 40 5 1
A blue 70 1 3
A yellow 80 1 2
B yellow 20 4 1
D blue 70 4 2
C blue 10 3 1
what i need is something more like this
ID BROWN SIZE TYPE BLUE SIZE TYPE YELLOW SIZE TYPE
A 1 20 1 1 0 3 1 80 2
B 0 0 0 0 0 0 4 20 1
C 0 0 0 3 10 1 2 20 1
D 5 40 1 4 0 2 0 0 0
I most like could accomplish this with an excel formula, possibly the one called sumifs but i can not seem to get it to work any help with this would be greatly appriciated.
You can do this by using a combination of SUM and IF in array formulas.
Assuming that your data table starts in cell A1 and your result table starts in cell A11, begin by entering the following formulas in cells B12, C12 and D12 respectively, making sure to use the CONTROL-SHIFT-ENTER key combination to enter them.
B12 =SUM(IF($B$2:$B$9=B$11,IF($A$2:$A$9=$A12,$D$2:$D$9,0)))
C12 =SUM(IF($B$2:$B$9=B$11,IF($A$2:$A$9=$A12,$C$2:$C$9,0)))
D12 =SUM(IF($B$2:$B$9=B$11,IF($A$2:$A$9=$A12,$E$2:$E$9,0)))
Copy the cells down to the bottom of your data table, which in this example would be row 15.
Then copy the block of formulas you have created to cell E12, where the BLUE section of the result table starts. Then copy the same block of formulas to cell H12, where the YELLOW section of the result table starts.
This solution assumes that you have no duplicate combinations of ID and COLOR in your data table and that no combinations are missing. If there are missing combinations of ID and COLOR, you would need to wrap the formulas in an IFERROR function (in Excel 2010).
The way I'd transpose a data table would run like this...
Your example is a bit more complicated so I'm not going to use your full data, just go with size. Begin by creating a column called Index
A B C D
INDEX ID COLOR SIZE
=A3 & "-" & B3 A brown 20
=A4 & "-" & B4 C yellow 10
. D brown 40
. A blue 70
. A yellow 80
. B yellow 20
D-blue D blue 70
C-blue C blue 10
Create a table equivalent which combines the header row with the ID column
F G H I
ID brown blue yellow
A =$F2 & "-" & G$1 . .
B . . .
C . C-blue C-yellow
D . D-blue D-yellow
Finally wrap this up in a VLOOKUP or an OFFSET(MATCH(_)) with possible an IFERROR
ID brown blue yellow
A =IFERROR(VLOOKUP($F2 & "-" & G$1,$A$3:$D$10,4,FALSE),"Err")
B . . .
C . 10 10
D . 70 Err
Anyway that is how I generally do this sort of transform

Resources