Matching multiple string values in two columns in Alteryx - alteryx

Is it possible to compare strings in two different columns? I want to achieve something like this " If [field1] = [field2] ". My first thought is to use the filter tool but its a malformed statement. 

What is your goal? If your goal is to filter where [field1] = [field2] then yes, that's exactly what the Filter tool does, (see link).
If you're trying to generate new data based on various conditions, you can use their Formula Tool, wherein you can utilize Conditional Functions. Simple example: creating a new variable, say, [NewVariableName], with an expression something like:
IF [field1] = [field2] THEN
"Hey they're equal!"
ELSE
"Nope, not equal!"
ENDIF

Related

Create a search option in Power BI dashboard based on keywords table

I have two tables
With complete data, including a keywords columns. where keywords are comma separated (around 25 keywords)
Unique keywords extracted from the keywords column. (single column with each keyword in each observation)
Task is, based on the keyword in the second table, search the observations that have similar keywords and display on the report.
Looks something like this:
This is a filter, which is not fulfilling my task.
(or)
I am back of https://ideas.powerbi.com/ideas/idea/?ideaid=a586deac-c465-48da-978b-30ac2a4a3245 this activity. if someone can provide any solution related to this, will be helpful :).
I'm not sure what do you try to achieve. If you want just filter some visualization by selecting one of the keywords then create a measure (returning 0 /1, and this we can use for the filter in visualization) using SELECTEDVALUE -> for grabbing selected slicer and pathcontains (you need to replace comas ", " to pipe "|"
https://dax.guide/pathcontains/

Display multiple results using an Nested if statement

Display multiple results using an Nested if statement.
Is there a way to display multiple results from a nested if statement? or how do i change it to do so.
I am currently using:
=IF(H3="Yes",D3,IF(AD3="Yes",E3,IF(AZ3="Yes",F3,"None")))
If more than one is yes I would like to display both results.
Would I need to create a long IF(AND( statement including all of the possible outcomes or does someone know a quicker way ??
The order in your formula is incorrect.
First you need to check all the ANDs and then you can check for the single occurrences. So, your formula should start with
=if(AND(H3="Y‌​es";AD3="Yes";AZ3="Yes");D3&E3&F3);if(and(H3="Y‌​es";AD3="Yes");D3&E3...
and towards the end of your formula you are adding the single checks
if(H3="Yes",D3,if(AD3="Yes",E3,...

More efficient way than nested ifs

In Excel, I want to use something other then nested if statements to execute a task. Is there a cleaner way of doing cases besides nested if statements? Is there a cases statement in excel? For example given a ordered tuple with ones and zeros (e.g (1,1,0)), I want the value of a cell to be something. Can I specify the ordered tuples in advance without something besides nested if statements?
If you already know the ordered tuples and what you want the final value to be, why not create a reference table somewhere else on your sheet with Col1 = tuple ; Col2 = Wanted output?
Then just use a Vlookup() statement on that table...
Hope this makes sense / does what you want....

Using SQL "IN" Function in Excel

Is there an "IN" type function like the one used in sql that can be used in excel? For example, if i am writing an If statement in excel and I want it to check the contents of a cell for 5 different words can i write something like:
=If(A1=IN("word1","word2","word3","word4","word5"),"YES","NO")
You could use MATCH :
=MATCH(A1, {"word1","word2","word3","word4","word5"}, 0)
which will return the index of the matching item in the array list. The trailing 0 means it should be an exact match. It will return #N/A if it isn't there, so you can tag a IF(ISNA( onto the front to make it behave like your "IN":
=IF(ISNA(MATCH(A1, {"word1","word2","word3","word4","word5"}, 0)),"NO","YES")
Note the change in order of the "YES" and "NO"
=IF(OR(A1={"word1","word2","word3","word4","word5"}),"YES","NO")
I think an improvement on
=IF(OR(A1={"word1","word2","word3","word4","word5"}),"YES","NO")
would be to use
=IF(OR(A1={"word1","word2","word3","word4","word5"}),A1,"NO");
which is more like the SQL's IN clause.
Use the OR function. It operationes very similiar to what you are looking for.
IF(OR(A1="word1",A1="word2",A1="word3")=TRUE,"Yes","No")
Also doesn't require the ctrl+shift+enter when using.

Translating strings postgres

I'm trying to translate 2 types of data using only postgres SQL
I've got a column "type" that may contains the kind of data.
type is a string column and may have "ACTUAL" or "OLD" values
+-type-+
+ACTUAL+
+OLD +
+------+
when I show the list with a lot of other joins I would like to show only "A" or "O" values
I couldnt find other way to do this than:
SELECT replace(replace(mytable.type, 'ACTUAL', 'A'),'OLD', 'O');
With that I can replace the text the way I need,
but I was looking for some more function using an array as parameter.
something like a cross-reference simple function:
translate(['ACTUAL','OLD'], ['A','O'])
Does anyone know a way to do this that doesn't use SQL views and neither needs another table like joining the results of this value with other table?
Thanks in advance,
Andre
I would use something like CASE...
SELECT
(CASE type
WHEN 'ACTUAL' THEN 'A'
WHEN 'OTHER' THEN 'O'
ELSE '?' END)
FROM
Using this method, you can return whatever you want based on whatever criteria you want, not just sub-stringing.

Resources