I am preparing a mailmerge that displays a text "Everything is included" if atleast one of the field values is "yes", but does not Display anything if all of the field values is "No"
My code is currently {IF{MERGEFIELD field1}="yes" OR{MERGEFIELD field2}="yes" OR {MERGEFIELD field3}="yes" OR {MERGEFIELD field3}="yes" OR {MERGEFIELD field4}="yes"} "Everything is included" ""}
But I keep getting error of conditional OP
As far as I can tell from my research, AND and OR are not valid in Word merge fields https://wordmvp.com/FAQs/MailMerge/MMergeIfFields.htm. Emulate this logic with nested IF.
{IF {MERGEFIELD field1} = "yes" "Everything is included"
{IF {MERGEFIELD field2} = "yes" "Everything is included"
{IF {MERGEFIELD field3} = "yes" "Everything is included"
{IF {MERGEFIELD field4} = "yes" "Everything is included" ""}}}}
Assuming there are 5 fields, use:
{IF{MERGEFIELD field1}= "yes" {IF{MERGEFIELD field2}= "yes" {IF{MERGEFIELD field3}= "yes" {IF{MERGEFIELD field4}= "yes" {IF{MERGEFIELD field5}= "yes" "Everything is included"}}}}}
or:
{IF«field1»= "yes" {IF«field2»= "yes" {IF«field3»= "yes" {IF«field4»= "yes" {IF«field5»= "yes" "Everything is included"}}}}}
Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac or, if you’re using a laptop, you might need to use Ctrl-Fn-F9); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. Likewise, the chevrons (i.e. '« »') are part of the actual mergefields - which you can insert from the 'Insert Merge Field' dropdown (i.e. you can't type or copy & paste them from this message, either). The spaces represented in the field constructions are all required.
The OR function can only test numeric values.
Assuming there are 5 fields, use:
{IF{={IF{MERGEFIELD field1}= "yes" 1 0}+{IF{MERGEFIELD field2}= "yes" 1 0}+{IF{MERGEFIELD field3}= "yes" 1 0}+{IF{MERGEFIELD field4}= "yes" "yes" 1 0}+{IF{MERGEFIELD field5}= "yes" "yes" 1 0}}> 0 "Everything is included"}
or:
{IF{={IF«field1»= "yes" 1 0}+{IF«field2»= "yes" 1 0}+{IF«field3»= "yes" 1 0}+{IF«field4»= "yes" "yes" 1 0}+{IF«field5»= "yes" "yes" 1 0}}> 0 "Everything is included"}
Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac or, if you’re using a laptop, you might need to use Ctrl-Fn-F9); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. Likewise, the chevrons (i.e. '« »') are part of the actual mergefields - which you can insert from the 'Insert Merge Field' dropdown (i.e. you can't type or copy & paste them from this message, either). The spaces represented in the field constructions are all required.
Related
I am looking for help updating an expression used in a SSRS report.
The current expression is something like this:
=IIF(Fields!Type.Value = "TKT", "Ticket No.",
IIF(Fields!Type.Value = "CUN", "Customer Number",
IIF(Fields!Type.Value = "ANM", "Account Number",
IIF(Fields!Type.Value = "CID", "Client ID", ""))))
We have added a few more "Types"
So for Type "TKT" now we have: "TKT1", "TKT2". For Type "CUN", now we have "CUN1", "CUN2, and so on for the last 2.
I am not familiar with how when using an IIF function, multiple values can be specified (similar to an IN operator).
If anyone could share some light regarding how this is done, that would be awesome.
Thank you for your help in advance.
You would probably be better off converting this expression to a SWITCH statement before this thing gets out of hand. A SWITCH accepts as many conditional and result pairings as you need to add. The following expression allows you to add as many checks as you need and the final pairing true,"" simply sets any that don't match the switch statement to a blank value.
=SWITCH(Fields!Type.Value = "TKT1", "Ticket No.",
Fields!Type.Value = "TKT2", "Ticket No.",
Fields!Type.Value = "CUN1", "Customer Number",
Fields!Type.Value = "CUN2", "Customer Number",
Fields!Type.Value = "ANM", "Account Number",
Fields!Type.Value = "CID", "Client ID",
[add additional pairings here],
true, "")
An additional solution would be to use the Contains keyword in SSRS. This would search the string to find a particular substring. You could simply modify each conditional to the following which would return true if the field contains that substring.
Fields!Type.Value.Contains("TKT")
I am searching for synonyms for a particular phrase from a dataset. I have 2 JSON files in which data is stored consisting of synonyms for yes and no . If I query for "not interested" it gives both yes and no phrases/synonyms as result, the expected result is just no phrases/synonyms.
en-gen-yes.json
{
"tag":"en-gen-yes",
"phrases": [
"yes",
"yeah",
"sure",
"suits me",
"interested"
]
}
en-gen-no.json
{
"tag":"en-gen-no",
"phrases": [
"no",
"nope",
"not sure",
"does not suits me",
"not interested"
]
}
query code
query := bleve.NewMatchPhraseQuery("not interested")
req := bleve.NewSearchRequest(query)
req.Fields = []string{"phrases"}
searchResults, err := paraphraseIndex.Search(req)
if err != nil {
log.Fatal(err)
}
if searchResults.Hits.Len() == 0 {
fmt.Println("No matches found")
} else {
for i := 0; i < searchResults.Hits.Len(); {
hit := searchResults.Hits[i]
fmt.Printf("%s\n", hit.Fields["phrases"])
i = i + 1
}
}
The result comes as
[no nope not sure does not suits me not interested]
[yes yeah sure suits me interested]
Expected Result is only
[no nope not sure does not suits me not interested]
The reason that it matches both is that the MatchPhraseQuery you are using will analyze the search terms. You didn't show the IndexMapping here so I can't be sure, but I'll assume you're using the "standard" analyzer. This analyzer removes English stop words, and the English stop word list is defined here:
https://github.com/blevesearch/bleve/blob/master/analysis/lang/en/stop_words_en.go#L281
So, this means that when you do a MatchPhraseQuery for "not interested" you end up just searching for "interested". And that term happens to also be in your "yes" list of synonyms.
It is worth noting that there is a variant called PhraseQuery (without Match) that does exact matching. And while that wouldn't remove the word "not" at search time, it still wouldn't find the match. And the reason is that the word "not" has been removed at index time as well, so and exact match of "not interested" would not find any matches (neither yes or no).
The solution is configure a custom analyzer which either doesn't remove any stop words, or that uses a custom stop word list that doesn't contain the word "not". If you do this, and use it for both indexing and searching, the query you're using should start to work correctly.
In SSRS (2014) I have created the Placeholder.
The value of Placeholder is picks from SQL 2014 DB StoredProcedure.
In the Placeholder properties, I have below expression,
=Parameters!BRN.Value
When I run the report,
Step 1: Report asks BRN value (which is integer). When I enter value
as "1"
Step 2: Report displays 1
If I pass BRN value as 2
it displays 2
But I want below results,
Step 1: When Report asks BRN value (which is integer). If I enter value
as "1" then it should display as "Winter"
or If I enter value
as "2" then it should display as "Summer"
or If I enter value
as "3" then it should display as "Spring"
or If I enter value
as "4" then it should display as "Sunny"
How can I do this please?
=Switch(Parameters!BRN.Value = 1, "Winter", Parameters!BRN.Value = 2, "Summer", Parameters!BRN.Value = 3, "Spring", Parameters!BRN.Value = 4, "Sunny")
I'd like to do something like this:
["START", "a", "b", "c", "STOP", "START", "d", "e", "STOP"].each do |message|
if message == "START"
Transaction.begin
elsif message == "STOP"
Transaction.commit if Transaction.active?
else
begin
Message.create!(body: message)
rescue
Transaction.rollback
end
end
end
In short, I have a stream of 'messages' and I'd like to transactionalise parts of that stream.
Whenever a "START" appears on the stream, a new transaction is begun. Whenever a "STOP" appears, the transaction is committed.
I'm struggling with the transactions.
I can see that I can do ActiveRecord::Base.transaction do ... end, but that won't work in this case unless I batch everything up, which isn't possible here because of the streams.
I saw that there's a transaction manager buried in ActiveRecord that I could potentially use (https://github.com/rails/rails/blob/0d76ab9c6f01e6390ba8878a296ff9d3ac6b9aa8/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb) but I haven't been able to get my tests passing against it.
I think part of the problem is also RSpec's transactional fixtures interfering, although disabling these didn't seem to solve the problem either.
Any help would be appreciated.
Thanks
you can manage transaction the following way
manager = ActiveRecord::Base.connection.transaction_manager
...
manager.begin_transaction
...
manager.commit_transaction
...
manager.rollback_transaction
or in your case
manager = ActiveRecord::Base.connection.transaction_manager
["START", "a", "b", "c", "STOP", "START", "d", "e", "STOP"].each do |message|
if message == "START"
manager.begin_transaction
elsif message == "STOP"
manager.commit_transaction
else
begin
Message.create!(body: message)
rescue
manager.rollback_transaction
end
end
end
I'd do this:
messages.chunk {|value| value != 'START' && value != 'STOP'}.each do |is_data, bodies|
if is_data
Message.transaction do
bodies.each {|body| Message.create(body: body)}
end
end
end
The first step is to use chunk to group the messages. The output of this is an array of pairs. If the first value of the pair is true, then the second value is the array of bodies, if not the bodies are just true false. With the data thus reorganised it is then trivial to use the existing transaction method.
I am starting out, so this code may not be as efficient as it could be, but I try. This is a text based game, something happens and the player must decide if he wants to continue or not.
but Everyone is different. so everyone is going to answer with some variation of "yes". How can I get the program to move on if someone types any variation of "yes" the commas give me a syntax error, and i don't know how else to get it to separate the possible answers.
def continueyn():
option1_des1 = raw_input("> ")
if option1_des1 == "yes", "Yes", "forward", "Forward", "Full impulse", "Full Impulse", "yeah", "yup", "Yup", "Yeah":
gravityp1()
elif option1_des1 == "no":
bearing(), userinput()
else:
print "Sorry Captain, I didn't get that. What did you say?"
continueyn()
Using 'or', as pointed out in the comments is incorrect. The correct way to go ahead through this would be either using lists and a loop, or iterating using "in":
Method 1:
option1_des1 = raw_input("> ")
if option1_des1 in {"yes", "Yes", "forward"} :
print "yes"
elif option1_des1 == "no":
print "no"
else:
print "Sorry Captain, I didn't get that. What did you say?"
Method 2:
You can also make a list and then go across values of the list like this-
flag=True
yesList = ['yes', 'Yes', 'forward']
option1_des1 = raw_input("> ")
for element in yesList:
if option1_des1 == element:
print "yes"
flag=False
break;
if option1_des1 == "no" and flag:
print "no"
elif flag:
print "Sorry Captain, I didn't get that. What did you say?"
Even better, you can use regex to match several variations of one type instead of figuring out every permutation. The xample below only covers "yes", but you can make a list of words like in method 2.
import re
pattern = 'yes'
option1_des1 = raw_input("> ")
matchObj = re.search(pattern, option1_des1, re.I)
if matchObj:
print "yes"
elif option1_des1 == "no":
print "no"
else:
print "Sorry Captain, I didn't get that. What did you say?"
Similar to sbhatla's answer you could use a list and use the built in "in" function which returns as a boolean.
yesoptions = ["yes", "Y", "etc"]
if option_des1 in yesoptions:
#runs actions for a yes answer
elif option in:
etcetc
else:
etc..