Example of using #ViewTitle with NSFSearch? - lotus-notes

I spent all of yesterday trying to make NSFSearch work with #ViewTitle, but I can't figure it out. The documentation has this to say:
ViewTitle - The address of a null-terminated string that contains a
view name. If the selection formula specified by the 2nd argument
(hFormula) contains the #ViewTitle function, then Domino or Notes uses
the view name specified by this argument (ViewTitle) to resolve this
#ViewTitle function.
If the selection formula specified by the 2nd argument (hFormula) does
not contain the #ViewTitle function, or if you are not using a the
selection formula (hFormula is NULLHANDLE), then set this argument
(ViewTitle) to NULL.
But I can't find a single example of this anywhere and can't make it work with selection formulas like these:
#ViewTitle = "Test Folder" & #Created < #Date(2021;1;1)
#ViewTitle & #Created < #Date(2021;1;1)
An example or pointer in the right direction would be greatly appreciated.

I've never found a reason to use this, but I've always interpreted it to mean that you can compile a selection formula like "DocType = #ViewTitle". Then you can call NSFSearch three times, once using "Draft" as the second argument, once using "In Progress" as the second argument, and once using "Final" as the second argument. The compiled formula will run as DocType = "Draft" for the first call, DocType = "In Progress" for the second call, and docType = "Final" for the third call. You get back three results, as if you were searching three different views, but you only had to call one NSFFormulaCompile three NSFSearch calls

Related

Returning a column reference from MATCH to avoid using INDIRECT with a Named Range

TL;DR: I'm basically trying to obtain a column range such as 'Sheet 1'!$A:$A where the A is obtained by matching the contents of a given cell to a 1:1 range within a sheet referenced by another given cell, for use in a dynamic range.
In the highly probable case where that made zero sense, here's an illustration:
PARAMETERS: A2 = "LIST" | C2 = "FirstName" | Desired result: 'LIST'!$A:$A
And I've obtained that, BUT, I can't use that output ('LIST'!$A:$A) within formulas (namely to create a dynamic range). For instance, here 'LIST'!$A:$A contains 101 cells with values in them:
V3 = NamedFormula = 'LIST'!$A:$A
COUNTA(INDIRECT(V3)) = 101
COUNTA(INDIRECT(NamedFormula)) = 1 because it evaluates to #VALUE and that is a singular result.
Before delving into the topic of using INDIRECT with a Named Range (which I've read about and am still getting over my confused grief), I'm realizing my Names are getting a bit out of hand. I tend to use Excel like a mad scientist. So, in case there's a much simpler solution to what I'm trying to do, here's my actual mission:
0. I'm building a tool to simplify a process where email addresses are built from different data, which needs to run without any scripts, only formulas.
1. A tab with no imposed name would contain a user database with minimally (firstname and lastname OR IDs) AND (potentially other data columns) in no specific order. Tool users would import that tab from wherever the data got to them depending on the client, and would only need to copy-paste relevant headers to the main tab without changing anything else here for data integrity.
2. The main tab would have specific input fields where tool users would paste in the name of the imported tab as well as the labels of the columns they need (for instance, the labels in the first row of the columns containing the first name and the last name), and an input field for the domain name to use to build those email addresses.
3. A Data tab is referenced for cleaning and preparing strings for email address formats.
4. The Export tab would spew out a list of clean email addresses that can be exported to CSV.
The Data tab is just 2 columns to use with SUBSTITUTE so that for instance apostrophes are removed but accented letters are normalized (é -> e). I've used LAMBDA within Names to get there. The problem is to tie everything in - to get those Named ranges into the final formula.
The Names I'm using so far (I'd like to use fewer but testing specific parts extended beyond simple usage I fear):
ALPH ={"A";"B";"C";"D";"E";"F";"G";"H";"I";"J";"K";"L";"M";"N";"O";"P";"Q";"R";"S";"T";"U";"V";"W";"X";"Y";"Z"}
LABELS =LAMBDA(labelname,ADDRESS(2,MATCH(labelname,INDIRECT("'"&PARAMETERS!$A$2&"'!$1:$1"),0),1,1,PARAMETERS!$A$2))
RANGECOL =LAMBDA(labelname,COLUMN(INDIRECT(LABELS(labelname))))
RNCOL =LAMBDA(label,"'"&PARAMETERS!$A$2&"'!$"&INDEX(ALPH,RANGECOL(label))&":$"&INDEX(ALPH,RANGECOL(label)))
I haven't tied everything in the Data tab yet - I'm still trying to automate my main tab before pushing further and using the Data tab substitutions on top of everything. That will be the next step, not my current focus. But, for the curious and interested, on the Data tab I'm using something something I found on ablebits which works wonders =]
So, now if I use the offset range with a static LIST!A:A it works:
=IF($C$2<>"",LOWER(INDEX(OFFSET(INDIRECT(ADDRESS(2,MATCH($C$2,INDIRECT("'"&$A$2&"'!$1:$1"),0),1,1,$A$2)),0,0,COUNTA(LIST!A:A)-1,1),ROW())),"") &IF($C$3<>"","."&LOWER(INDEX(OFFSET(INDIRECT(ADDRESS(2,MATCH($C$3,INDIRECT("'"&$A$2&"'!$1:$1"),0),1,1,$A$2)),0,0,COUNTA(LIST!A:A)-1,1),ROW())),"") &"#"&$C$4
But when I try to use the dynamic RNCOL($C$3) it does not:
=IF($C$2<>"",LOWER(INDEX(OFFSET(INDIRECT(LABELS($C$2)),0,0,COUNTA(INDIRECT(RNCOL($C$2)))-1,1),ROW())),"") &IF($C$3<>"","."&LOWER(INDEX(OFFSET(INDIRECT(LABELS($C$3)),0,0,COUNTA(INDIRECT(RNCOL($C$3)))-1,1),ROW())),"") &"#"&$C$4
This just gives #REF, and evaluating shows the digression starting at INDIRECT(RNCOL($C$3)) equating to #VALUE.
I'm starting to see double here but my undying and completely normal love for Excel prevents me from going home from work as I'm way too far down the rabbit hole to let my obsession die here.
Any pointers as to how this can work?
Note - all of the names in the supplied sheet were generated by an online fake name generator, nothing in here is actual user data #GDPR
Thanks in advance! <3
Test sheet is available via Google Drive.
Your current set-up is not good for many reasons, and in my opinion would require a complete overhaul, the scope of which lies beyond a response on this website.
As to a 'quick fix' to your current issue, the reason your formula in E1 is currently returning an error is due to the fact that, as you can see via stepping through with the Evaluate Formula tool, the part
COUNTA(INDIRECT(RNCOL($C$2)))-1
is resolving to
COUNTA(INDIRECT({"'LIST'!$A:$A"}))-1
and this is not the same as
COUNTA(INDIRECT("'LIST'!$A:$A"))-1
in that the value being passed to INDIRECT is an array in the former though not in the latter. Although INDIRECT can accept arrays, it is only within certain constructions in conjunction with other suitable functions; here it will simply error.
And the reason that it is returning an array is due to the fact that RNCOL($C$2) is returning an array, and that is because that function is defined as
=LAMBDA(label,"'"&PARAMETERS!$A$2&"'!$"&INDEX(ALPH,RANGECOL(label))&":$"&INDEX(ALPH,RANGECOL(label)))
and, since RANGECOL($C$2) resolves to 1 here, the above is equivalent to
"'PARAMETERS!$A$2'!$"&INDEX(ALPH,1)&":$"&INDEX(ALPH,1)
Here, because you are omitting the column_num parameter from INDEX, the part
INDEX(ALPH,1)
is resolving to
{"A"}
which is an array (albeit one comprising a single value) and technically different from
"A"
In most circumstances, this is not an issue. As such, it is almost always unnecessary to pass both a row_num and column_num parameter to INDEX when indexing a one-dimensional array. Here, however, it matters.
You can resolve this by explicitly including a column_num parameter, i.e. redefine RNCOL as
=LAMBDA(label,"'"&PARAMETERS!$A$2&"'!$"&INDEX(ALPH,RANGECOL(label),1)&":$"&INDEX(ALPH,RANGECOL(label),1))

How to use IF function with 3 arguments while ignoring blanks

Okay so my question is how do i use IF with 3 arguments while one of the arguments is "Ignore blanks".
If A1 is "Escalation_complaint or "Escalation_request" B1 must show "Escalated".
If A1 is any other text, B1 must show "Solved"
If A1 is blank, B1 must remain empty.
Can someone please help me figure this out?
Your first test must be whether the A1 is empty or not. This must be the first because if you test whether an empty string is contained in another string the answer is always yes. =SEARCH("","Something") returns 1. So, How do you test for an empty cell? I recommend Excel's COUNTA() function but you may prefer testing for "". So, let's say, your first test is this.
=IF(COUNTA(A1), True, False)
Some would say IF(COUNTA(A1)>0, True, False) and that is equivalent. The simple IF(COUNTA(A1) tests for non-zero. Any number other than zero returns True.
So, now you got your basic function. What's supposed to happen if the result is True? What do you want to happen if the result is False? The latter is easy. If the result is False you want a null string returns. So, now your formula looks like this:-
=IF(COUNTA(A1), True, "")
Observe that we simply replaced the False with the desired output. So, what do you want to happen if A1 has something in it, if the first test resulted in True? There are two possibilities. That makes the problem solvable with a single IF. IF A1 has something starting with "Escalation" in it the result should be "escalate", else it should be "solved". So, how do you test for cell content?
=Find("escalation", A1) will not find "Escalation" (with a capital E). Therefore I recommend SEARCH(), which does.
=SEARCH("escalation", A1) should return 1. If it returns 1 your problem is solved because if it returns any other number its not "escalated" but "solved". Unfortunately, there is a third option. It might return an error. In fact it will return an error every time the word isn't found. That gives you a 3-way possibility (1, bigger than 1, or Error) which can't be solved with a single IF. So, I suggest to avoid the error.
=Find("escalation", A1 & "escalation") will find the word "escalation" every time. But it will find it in first position only if the conditions for "Escalate" is met. Therefore the formula for the True condition in the basic formula must be this:-
IF(SEARCH("escalation", A1 & "escalation") = 1, "Escalated", "Solved")
That's it. Assemble the second IF into the first and you're done.
So, using two if(), and minimising the testing you need :
=IF(left(A1,3)="Esc","Escalated",IF(A1="","","Solved"))
Edit: Based on a comment to another answer, if testing for "esc" only could lead to problems then how about:
=IF(left(A1,5)="Escal","Escalated",IF(A1="","","Solved"))
Which will avoid words like "escaped" or "escargot"...
If you know that the text will always be Escalation_complaint or Escalation_request, you can do this with a nested IF query. =IF in Excel takes three parameters: what to verify, result if true, and result if false. You can have another IF statement in the what to do if it returns false section. We can also do an OR() statement to verify both Escalation_complaint and Escalation_request. The result looks like this:
=IF(OR(A1="Escalation_complaint",A1="Escalation_request"),"Escalated",IF(A1="","","Solved"))
The order here is important because you want the "for all other cases" to be in the final IF statement.
If you have a situation where you could also have "Request_escalation" or "complaint_escalation", you should make a more general solution that uses SEARCH or FIND which would allow you to do a more general lookup that allows for more values without having to hardcode them. Here is an example that makes it possible to find the word Escalation anywhere in the cell:
=IF(IFERROR(SEARCH("escalation",A1,1),0)>0, "Escalated", IF(A1="","","Solved"))
Excel have maximum 30 arguments in a formula.
= if (A1=1, "True",if(B1>2,"True", "false"))
Understand this pattern. easy way.
If you no longer understand this, or if your problem has not been resolved, attach a file or screenshot that relates to your problem.

Excel, equation to output either 'Agent name', "COPY", or "Not Found"

I had an excel test that I didn't do particularly well on, but this one question had me stumped. I need an equation that takes the name in this list and outputs the agent name in 'first.initial' or "COPY" or "NOT FOUND"
Sheet 1:
Agent 
Adam.m
Agent 
David.e
Agent 
Joe.A 
Agent
Ben.B
Agent
Kat.C
Agent
Training.22
Agent
Admin
Convert these names: Correct output:
David Everit David.e
Joe a. Joe.A
Ben Ben.B
Sam p. NOT FOUND
Training 22 Training.22
David E. COPY
Kat Cathy Kat.C
David D. NOT FOUND
Adam.S NOT FOUND
The equation I submitted that my teacher said was wrong was:
=IFNA(IF(COUNTIF(Sheet1!A:A, A3)>1, "COPY", INDEX(Sheet1!A:A,MATCH(A3&"*",Sheet1!A:A,0))),"Not Found")
Well here's the thing.
You are checking the original data source for the name, pre-conversion. I must admit, the COPY was a bit misleading at first but I caught on later.
You are also wrapping the whole thing in a single logical... ISNA()... Your formula can only return TRUE, FALSE or an error from this.
Putting the wrapped ISNA() aside, this means that for your formula the majority of these entries are Not Found. True, if you instead had a list of data that had already been manipulated this would almost succeed. But you are checking for the "COPY" in the wrong data...
Your first task here would be to manipulate the data to the desired format of '[Firstname].[initial]' // So assuming that the first set of characters in the cell is always going to be the forename you can use a combination of something like:
=LEFT(A2,SEARCH(" ",A2)-1) - Gets the forname by returning the left-most characters to a length of the first space position minus 1.
=RIGHT(A2,LEN(A2)-SEARCH(" ",A2)) - Gets all characters to the right of space by determining the legth from the right as the total cell length minus the position of space.
You will need to perform a logical on the second scenario though as you want a single letter is it is a word or the entire thing if it is a number:
=IFERROR(RIGHT(A2,LEN(A2)-SEARCH(" ",A2))-0,MID(A2,SEARCH(" ",A2)+1,1))
So what i have done here is attempt to remove 0 from the string, if it is a number, this will succeed and return that number to us. If it fails it will produce an error and progress on to the second clause, giving us the single character.
You can combine these using simple string building or a concatenate clause:
=LEFT(A2,SEARCH(" ",A2)-1)&"."&IFERROR(RIGHT(A2,LEN(A2)-SEARCH(" ",A2))-0,MID(A2,SEARCH(" ",A2)+1,1))
or
=CONCATENATE(=LEFT(A2,SEARCH(" ",A2)-1),".",IFERROR(RIGHT(A2,LEN(A2)-SEARCH(" ",A2))-0,MID(A2,SEARCH(" ",A2)+1,1))
So now we are almost there, except that Ben and Adam are producing errors as there isn't a space character that can be found. We'll handle that error now so that we can move on to our search:
=IF(ISERROR(SEARCH(" ",A2)),A2,LEFT(A2,SEARCH(" ",A2)-1)&"."&IFERROR(RIGHT(A2,LEN(A2)-SEARCH(" ",A2))-0,MID(A2,SEARCH(" ",A2)+1,1))) - if you cannot find a space character then we will have the whole cell, otherwise, we will use the space to build the search term.
Now that we have the text formatted in the way that we want it, we can move forward to do the search, the order is important as we will need to first check our results from above for duplicates and print "COPY" where found, then look for the match and return it if it's there and lastly return "NOT FOUND" if we cannot find it.
We are going to need the use of the wildcard in order to satisfy the entry Ben. So let's show the logic first then throw the whole formula together:
=IF(COUNTIF($B$1:B1,[SearchTermFormula]),"COPY", - This part of the formula uses countif to check whether the search term already exists above it, returns "COPY" if so and will continue to the next part, the absolute referencing ($$) is important so that the range updates as you copy the formula down but keeps the first cell locked.
IF(ISNUMBER(MATCH([SearchTermFormula]&"*",Sheet1!$A$1:$A$14,0)),[SearchTermFormula],"NOT FOUND") - So this works to show the basic logical, again we use IF() to determine whether a match can be made as a number would be returned if so. We can then return the search term itself or "NOT FOUND".
A more elegent version of this part though would be:
IFERROR(INDEX(Sheet1!$A$1:$A$14,MATCH([SearchTermFormula]&"*",Sheet1!$A$1:$A$14,0)),"NOT FOUND"))
As it actually returns the result from sheet1 as well as making us use the [SearchTermFormula] 1 less time, using less resources.
INDEX() essentially maps the range as a 1 based array. What that means is the first cell in the range is considered an address of 1,1. You can think of it adding X and Y axis but 0,0 is outside the top left and the Y axis is inverted.
So we get it to index column A and MATCH returns the relative position, as the row's are equally sized, the relative position will be the row number we are after so we get the result returned or an error value, so IFERROR() leads us on to produce "NOT FOUND".
Putting all that together we have:
=IF(COUNTIF($B$1:B1,IF(ISERROR(SEARCH(" ",A2)),A2,LEFT(A2,SEARCH(" ",A2)-1)&"."&IFERROR(RIGHT(A2,LEN(A2)-SEARCH(" ",A2))-0,MID(A2,SEARCH(" ",A2)+1,1))))>0,"COPY",IFERROR(INDEX(Sheet1!$A$1:$A$14,MATCH(IF(ISERROR(SEARCH(" ",A2)),A2,LEFT(A2,SEARCH(" ",A2)-1)&"."&IFERROR(RIGHT(A2,LEN(A2)-SEARCH(" ",A2))-0,MID(A2,SEARCH(" ",A2)+1,1)))&"*",Sheet1!$A$1:$A$14,0)),"NOT FOUND"))
Sorry for the essay but I hope it helps you understand the scope

How to get object method (object."something"), where method name comes from a list of strings ("something" is a string)?

I have a user form that contains lables. (I have to manually create each lable, since I can only place it in the correct spot by looking at the underlying image.) Each lable must go through the same "initializing" function that sets/re-sets its appearances. This leads to having the following:
dummy = Initialize(UserForm1.Lable1)
dummy = Initialize(UserForm1.Lable2)
dummy = Initialize(UserForm1.Lable3)
.
.
.
The names in my code are more descriptive, and I have the actual names for the lables stored in an excel sheet column. So, I would like to make a for loop that goes through that column, and substitutes ".Lable#" for ".(name from column)", like this:
For i = 1 to 10
dummy.Initialize(UserForm1.ThisWorkbook.Sheets("Sheet1").Cells(i,2))
Next i
The above code naturally doesn't work because the value from the cell is a string. Therefore, I need a way of converting that string to an object mothod name. Any ideas?
Hope this makes some sense, and that this is possible.
Thanks for your time,
Marvin
(I've learned all I know about VBA from the internet, so probably have some bad looking code. Suggestions for improvement are welcome).
For form controls, use the Controls method. This can be used on its own, or inside a loop:
for i=1 to 5
frmUserForm.Controls("Label" & i).Enabled = True
next i
Does that make sense?

How to find a string within a string

I have the list with like 100,000 site link strings
Each link is unique, but it has consistent ?Item=
Then, it's either nothing or it continues after & symbol.
My question is: How do I pull out the item numbers?
I know replace function can offer similar functionality, but it works with Fixed sizes, in my case string can be different in size.
Link example:
www.site.com?sadfsf?sdfsdf&adfasfd?Item=JGFGGG55555
or
www.site.com?sadfsf?sdfsdf&adfasfd?Item=JGFGGG55555&sdafsdfsdfsdf
In both cases I need to get JGFGGG55555 only
If this always is the last portion of the string, you can use the following:
=MID(A1, FIND("?Item=", A1) + 6, 99)
This assumes:
no item numbers will be over 99 digits.
no additional fields follow the item number.
Edit:
With the update to your question, it is apparent you have some strings with additional data after the ?Item= field. Without using VBA there is not a simple means of using MID and FIND to extract this.
However you could create a column which acts as a placeholder.
For example, create a column using:
=MID(A1,FIND("?Item=",A1)+6,99)
This gets you the following value: JGFGGG55555&sdafsdfsdfsdf
Next, create a column using:
=IF(ISERROR(FIND("&",B2)),B2,LEFT(B2,FIND("&",B2)-1))
This produces: JGFGGG55555 by searching the first value for a & and using the portion before it. If it is not found, the first value is simply repeated.
This formula should work for both the examples given:
=MID(A1,FIND("=",A1),IFERROR(LEN(A1)-FIND("&",A1,FIND("=",A1))-1,LEN(A1)+1-FIND("=",A1)))

Resources