shstrating
Board Regular
- Joined
- Sep 8, 2009
- Messages
- 65
- Office Version
- 365
- Platform
- Windows
I was graciously provided a LET formula by member felixstraube that I would now like to modify to include an additional check of the data and only return values that match this extra condition.
Here is the original LET formula: =LET(rd,$A$1:$A$131788, r_hasCCP,FILTER(ROW(rd),ISNUMBER(FIND("IM=LAM124",rd))), r_hasPO,FILTER(ROW(rd),ISNUMBER(FIND("PO=",rd))), textIndex,BYROW(r_hasCCP,LAMBDA(x,MAX(FILTER(r_hasPO,r_hasPO<x)))), TEXTAFTER(CHOOSEROWS(rd,textIndex),"PO=") )
I admit I do not fully understand how the textIndex BYROW calculation works or how the CHOOSEROWS in the final calculation works, but the formula got me the results I needed.
It queries my column of data to find every instance of "IM=LAM124" and then it looks backwards from IM=LAM124 and returns the value of the corresponding PO= field minus the "PO=" prefix.
I have the same single column of data that I now want to query for a slightly different condition with a slightly modified output.
So now I would like to modify this formula to do the following:
- Perform the same calculation as the original "r_hasCCP" function (to be renamed "r_hasUND") but looking for the string "ON=(UND)" instead of "IM=LAM124". (I know how to do this)
- When "ON=(UND)" is found then check the 9th row following that record and determine whether the string begins with "PO". (I don't know how to do the "...check the 9th row following..." bit)
- If "PO" is found, look backwards and return the value of the "PO=" entry that comes before the "ON=(UND)" that was found previously. (Maybe the existing TEXTAFTER calc in the original formula would still work?)
- If "PO" is not found, do nothing.
- Continue down the column of data performing the same steps.
By way of explaining the data a bit, all records that begin with "PO=" are what we call PO Tables.
Each PO= record is the beginning of a new PO table.
What I am trying to accomplish is to get a list of every PO Table that contains only one "ON=" record where that one "ON=" record must equal "ON=(UND)".
There may be PO Tables that contain only one "ON=" record that is not equal to "(UND)" and these are to be ignored.
In the following set of example data when the modified LET function (or other solution) is working properly it should return the result shown in C1 because the 9th row after the ON=(UND) in ColB Row28 begins with "PO".
DPGP-HVGRD-124 would be an incorrect result because the 9th row after the ON=(UND) in ColB Row5 begins with "ON".
Thanks in advance for any assistance offered.
Here is the original LET formula: =LET(rd,$A$1:$A$131788, r_hasCCP,FILTER(ROW(rd),ISNUMBER(FIND("IM=LAM124",rd))), r_hasPO,FILTER(ROW(rd),ISNUMBER(FIND("PO=",rd))), textIndex,BYROW(r_hasCCP,LAMBDA(x,MAX(FILTER(r_hasPO,r_hasPO<x)))), TEXTAFTER(CHOOSEROWS(rd,textIndex),"PO=") )
I admit I do not fully understand how the textIndex BYROW calculation works or how the CHOOSEROWS in the final calculation works, but the formula got me the results I needed.
It queries my column of data to find every instance of "IM=LAM124" and then it looks backwards from IM=LAM124 and returns the value of the corresponding PO= field minus the "PO=" prefix.
I have the same single column of data that I now want to query for a slightly different condition with a slightly modified output.
So now I would like to modify this formula to do the following:
- Perform the same calculation as the original "r_hasCCP" function (to be renamed "r_hasUND") but looking for the string "ON=(UND)" instead of "IM=LAM124". (I know how to do this)
- When "ON=(UND)" is found then check the 9th row following that record and determine whether the string begins with "PO". (I don't know how to do the "...check the 9th row following..." bit)
- If "PO" is found, look backwards and return the value of the "PO=" entry that comes before the "ON=(UND)" that was found previously. (Maybe the existing TEXTAFTER calc in the original formula would still work?)
- If "PO" is not found, do nothing.
- Continue down the column of data performing the same steps.
By way of explaining the data a bit, all records that begin with "PO=" are what we call PO Tables.
Each PO= record is the beginning of a new PO table.
What I am trying to accomplish is to get a list of every PO Table that contains only one "ON=" record where that one "ON=" record must equal "ON=(UND)".
There may be PO Tables that contain only one "ON=" record that is not equal to "(UND)" and these are to be ignored.
In the following set of example data when the modified LET function (or other solution) is working properly it should return the result shown in C1 because the 9th row after the ON=(UND) in ColB Row28 begins with "PO".
DPGP-HVGRD-124 would be an incorrect result because the 9th row after the ON=(UND) in ColB Row5 begins with "ON".
Thanks in advance for any assistance offered.
kbe3-NEW.xlsx | ||||
---|---|---|---|---|
B | C | |||
1 | PO=DPGP-HVGRD-124 | DPGP-HVGRD-125 | ||
2 | OG=Grain Direction | |||
3 | POLA=AFUFU-3D-GS-SD1 | |||
4 | POLA=AFUFU-3D-GS-SD2 | |||
5 | ON=(UND) | |||
6 | IM=UNDCOL | |||
7 | OD=*** Undecided Color *** | |||
8 | O1=0 | |||
9 | O2=0 | |||
10 | O3=0 | |||
11 | O4=0 | |||
12 | O5=0 | |||
13 | O6=0 | |||
14 | ON=H | |||
15 | IM=LAM124 | |||
16 | OD=OPT: Horizontal Grain Direction | |||
17 | O1=0 | |||
18 | O2=0 | |||
19 | O3=0 | |||
20 | O4=0 | |||
21 | O5=0 | |||
22 | O6=0 | |||
23 | SO=DPGP-LAM-EDGE | |||
24 | PO=DPGP-HVGRD-125 | |||
25 | OG=Grain Direction | |||
26 | POLA=AFUFU-3D-GS-SD1 | |||
27 | POLA=AFUFU-3D-GS-SD2 | |||
28 | ON=(UND) | |||
29 | IM=UNDCOL | |||
30 | OD=*** Undecided Color *** | |||
31 | O1=0 | |||
32 | O2=0 | |||
33 | O3=0 | |||
34 | O4=0 | |||
35 | O5=0 | |||
36 | O6=0 | |||
37 | PO=DPGP-HVGRD-126 | |||
kbe |