How can I produce this as a new column in an alteryx table? - alteryx

Each row needs to be paired up with the one before it therefore I need a new column that looks like the following.
flag
1
1
2
2
3
3
4
4
5
5
.
.
.
and so on

You can solve this a number of ways with Alteryx. I chose to use one tool, the Multi-Row Formula tool, to make an elegant solution.
Add the Multi-Row Formula tool.
Use the default "Create a New Field" option and name the field "flag".
Choose 2 as the "Num Rows".
Choose "NULL" as the "Values for Rows that don't Exist".
For the expression, paste the following:
IF ISNULL([Row-1:flag])
THEN 1
ELSEIF [Row-1:flag] == [Row-2:flag]
THEN [Row-1:flag] + 1
ELSE [Row-1:flag]
ENDIF
This will create the flag for you by paring the first and second rows, third and fourth, and so on.
As a reference, see my page in the Alteryx community. I am a certified partner.
Alteryx Reference

Related

Create a text cell value based on row entries and corresponding columns

I understand this is a tough way of wording the problem I have. Please try and help me.
I want to create a Column called Orders which contains cells based on corresponding item values.
So if I have columns: FlatNo, Truffle, Pineapple, Mango, Chocochips; I want to create a column called Orders which has value:
FlatNo - A51
Mango - 1
Chocochips - 1
(if no values in the Pineapple & Truffle Columns, none show up in Orders columns)
See image
How do I do that ? Thank you in advance
You can use IF and &. & simply puts the different desired things altogether.
Hope the following formula will get you the result for column orders. I have put the number of each item ordered inside parentheses before the item.
="Flat No. "&A2&IF(ISBLANK(B2),"","-("&B2&")"&$B$1)&IF(ISBLANK(C2),"","-("&C2&")"&$C$1)&IF(ISBLANK(D2),"","-("&D2&")"&$D$1)&IF(ISBLANK(E2),"","-("&E2&")"&$E$1)
For instance the third order is shown like this: Flat No. E-23-(1)Truffle -1 Pc Rs 60-(3)Mango -1 Pc Rs 60

VLOOKUP with conditions

I have an issue at the moment which I'm not able to resolve even with multiple combinations of If and Vlookups. I'm not doing this right.
I have a sheet which has the names of the products and an empty column for the Sl Number. The Sl number needs to be retrieved from Sheet 2 if it matches the value in the adjacent cell of the formula (This I know can be possible with Vlookup). However, I am trying to display the value even if the match is not exact. By that I mean if the product name has all the values as on the sheet 1 but also has additional information in brackets, then the value should still be displayed.
Sheet 1
Formula in A2 - A7 = "=VLOOKUP(B2, Sheet2!B:E, 2, 0)"
Sheet 2
The complete data
Is this possible?
Thanks in advance.
Apologies, I'm new here and not sure how this works. So trying to do the right thing but may take some time.
Thanks Frank and Tim. I have another extended question to this.
Is there a way to retrieve the value by ignoring text in brackets on the lookup cell itself?
For example:
Sheet 1
Sl Number Name
123454 Cream SPF 30+ 50g
**NA** Bar Chocolate 70g X 6 (Sample)
234256 Hand Wash 150ml
26786 Toothpaste - Whitening 110g
Sheet 2
ID Name Sl number Manufacturer Quantity
8 Collagen Essence 10ml 456788 AL 87
9 Hand Wash 150ml 234256 AD 23
10 Bar Chocolate 70g X 6 835424 AU 234
Row 2 on Sheet 1 has the name that includes (Sample) and the same product on sheet 2 does not contain the (Sample) for that product. Is there a way I can use lookup in the above scenario?
Thank you
Tim's comment
=VLOOKUP(B2 & "*", Sheet2!B:E, 2, 0) as long as the "Extra" info is tagged onto the end of the name, and none of your product names is a
substring of another product name. – Tim Williams 53 mins ago
Will get what you are looking for, as for getting rid of text between "(...)" use
=IFERROR(IF(FIND("(",A2),LEFT(A2,FIND("(",A2)-1),A2),A2)
To create a new column that will cut out anything that has parentheses "(...)" this presumes that all of your entries has the "(...)" at the end, i.e. far right side.
As you are new, I presume you might be interested in an explanation. I'll explain what Tim and I did. If I am incorrect, anyone is free to edit.
Based on your question, it would appear that you are familiar with Excel but not the site. This said, my understanding of the key difference between your attempt and Tim's was =VLOOKUP(B2 & "*", Sheet2!B:E, 2, 0) or specifically & "*". This introduces a Wildcard to the search parameter. So if you typed "Bob" but the actual reference was "Bob's Burger" That "*" would allow ['s Burger] to be included as part of the possible search given that you set vLookup to search for Approximate rather than exact matches. =VLOOKUP(B2 & "*", Sheet2!B:E, 2, 0) specifically , 0).
As for my part, IFERROR is effectively an catch-all for errors in IF functions. If there is a error, then X. In this case, if it does not find "(" in the cell, then it will throw an error. Since it is an error, display the original cell.
As for IF(FIND("(",A2),LEFT(A2,FIND("(",A2)-1),A2) It asks Excel to look for "(" in the cell A2, if it finds it, then it it counts from the LEFT until it finds the "(" and deletes the text one space to the left of the first "(". Thus removing the "(...)".

Excel -- Filter the first row from a list of values; for multiple values?

All,
I am currently faced with an issue where I need to fetch the first instance of a value in a column, but I have multiple values. No two rows will be the same EXCEPT for the first column.
Example:
A 1 !
A 2 #
B 3 #
B 4 $
C 5 %
C 6 ^
D 7 &
D 8 *
After filter:
A 1 !
B 3 #
C 5 %
D 7 &
Would anyone have a way to go about this? Thanks in advanced.
Edit: Jeeped literally pointed something out that I have been doing for a long time, but didn't even think would work in this instance.
To solve this item, utilize the "Remove Duplicates" on the column in question (Column 1), but make sure you expand the selection. However, uncheck all the columns, and recheck only Column 1 for the criteria.
Thanks.
I am assuming you are trying to extract unique values from each column. If so, Excel has a built in function called Advanced Filter, which will do exactly that.
This tutorial will familiarize you with the feature
http://www.excel-easy.com/examples/advanced-filter.html
Hope that helps

Excel use index match to return multiple values in a list

My worksheets:
ELKK BSN Voornaam Achternaam DOB Basisschool Advies Voorrangschool Voorkeur
1 1 John Smit 1 Test VWO Test Test
2 2 Chris Kong 2 Test 2 HAVO Test Test
This worksheet is called Leerlingen
The second one:
School Advies Klasnaam Regulier
Test VWO VWO 1
Test 2 HAVO HAVO 1
Test 3 VWO SPORT 0
This worksheet is called VO-scholen
What I want to happen is, when I change the value "Advies" in the Leerlingen worksheet. I want to get all the schools from the VO-scholen Worksheet who also have that "Advies" and return them in the Leerlingen worksheet into a list under the column "Voorrangschool".
This means that with "John Smit" I can select the schools Test and Test 3, and with "Chris Kong" I can select the school Test 2.
Here is what I already tried:
=INDEX('VO-scholen'!A2:G4;MATCH(G2; 'VO-scholen'!$C$2:$C$4; 0);2 )
But it won't return multiple values, only the first value it can find.
my answer requires MOREFUNC addon*
Here I assume data in purchase "table" is in A9:C11. Adjust accordingly.
formula for Leerlingen!H2:
=MCONCAT(IF('VO-scholen'!$C$2:$C$4=G2,'VO-scholen'!$B$2:$B$4,""),",")
notice the curly braces. This is an array formula you have to confirm using Ctrl+Shift+Enter, not just Enter (so that curly braces appear)
then copy the formula down
MOREFUNC ADDON
Morefunc Addon is a free library of 66 new worksheet functions.
HERE is some information (by original author)
here is the last working download link I found
here is a good installation walk-through video
You'll want to modify this a little, but try:
=INDEX('VO-scholen'!$A$1:$G$4,MATCH($G2, 'VO-scholen'!$B$1:$B$4, 0),1 ) & IF(COUNTIF('VO-scholen'!$B:$B,Leerlingen!$G2)>1, ", " & INDEX(OFFSET('VO-scholen'!$A$1:$D$4,MATCH($G2,'VO-scholen'!$B$1:$B$4),0),MATCH($G2,'VO-scholen'!$B$1:$B$4),1),"")
The first index match grabs the first value in the table. The second index match grabs the first value in an offset from the first table. The offset starts the second lookup table down the number of rows from the first lookup value. In other words if you were searching in B1:B100 and the value was found in row 3, the second lookup will be in B4:B104.

Return a row number that matches multiple criteria in vbs excel

I need to be able to search my whole table for a row that matches multiple criteria. We use a program that outputs data in the form of a .csv file. It has rows that separate sets of data, each of these headers don't have any columns that are unique in of them self but if i searched the table for multiple values i should be able to pinpoint each header row. I know i can use Application.WorksheetFunction.Match to return a row on a single criteria but i need to search on two three or four criteria.
In pseudo-code it would be something like this:
Return row number were column A = bill & column B = Woods & column C = some other data
We need to work with arrays:
There are 2 kinds of arrays:
numeric {1,0,1,1,1,0,0,1}
boolean {TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE}
to convert between them we can use:
MATCH function
MATCH(1,{1,0,1,1,1,0,0,1},0) -> will result {TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE}
simple multiplication
{TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE}*{TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE} -> will result {1,0,1,1,1,0,0,1}
you can can check an array in the match function, entering it like in the picture below, be warned that MATCH function WILL TREAT AN ARRAY AS AN "OR" FUNCTION (one match will result in true
ie:
MATCH(1,{1,0,1,1,1,0,0,1},0)=TRUE
, YOU MUST CTR+SHIFT+ENTER !!! FOR IT TO GIVE AN ARRAY BACK!!!
in the example below i show that i want to sum the hours of all the employees except the admin per case
we have 2 options, the long simple way, the complicated fast way:
long simple way
D2=SUMPRODUCT(C2:C9,(A2=A2:A9)*("admin"<>B2:B9)) <<- SUMPRODUCT makes a multiplication
basically A1={2,3,11,3,2,4,5,6}*{0,1,1,0,0,0,0,0} (IT MUST BE A NUMERIC ARRAY TO THE RIGHT IN SUMPRODUCT!!!)
ie: A1=2*0+3*1+11*1+3*0+2*0+4*0+5*0+6*0
this causes a problem because if you drag the cell to autocomplete the rest of the cells, it will edit the lower and higher values of
ie: D9=SUMPRODUCT(C9:C16,(A9=A9:A16)*("admin"<>B9:B16)), which is out of bounds
same as the above if you have a table and want to view the results in a diferent order
the fast complicated way
D3=SUMPRODUCT(INDIRECT("c2:c9"),(A3=INDIRECT("a2:a9"))*("admin"<>INDIRECT("b2:b9")))
it's the same, except that INDIRECT was used on the cells that we want not be modified when autocompleting or table reorderings
be warned that INDIRECT sometimes give VOLATILE ERROR,i recommend not using it on a single cell or using it only once in an array
f* c* i cant post pictures :(
table is:
case emplyee hours totalHoursPerCaseWithoutAdmin
1 admin 2 14
1 him 3 14
1 her 11 14
2 him 3 5
2 her 2 5
3 you 4 10
3 admin 5 10
3 her 6 10
and for the functions to check the arrays, open the insert function button (it looks like and fx) then doubleclick MATCH and then if you enter inside the Lookup_array a value like
A2=A2:A9 for our example it will give {TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE} that is because only the first 3 lines are from case=1
Something like this?
Assuming that you data in in A1:C20
I am looking for "Bill" in A, "Woods" in B and "some other data" in C
Change as applicable
=IF(INDEX(A1:A20,MATCH("Bill",A1:A20,0),1)="Bill",IF(INDEX(B1:B20,MATCH("Woods",B1:B20,0),1)="Woods",IF(INDEX(C1:C20,MATCH("some other data",C1:C20,0),1)="some other data",MATCH("Bill",A1:A20,0),"Not Found")))
SNAPSHOT
I would use this array* formula (for three criteria):
=MATCH(1,((Range1=Criterion1)*(Range2=Criterion2)*(Range3=Criterion3)),0)
*commit with Ctrl+Shift+Enter

Resources