if statement in access with multiple conditions - ms-access

I got this formula in excel I need to convert to access. I come up with this but the result will give all "accurate" result event if some are supposed to be "not accurate"
MRP Method Accurate:IIF([ITEM_TYPE]="PH"AND[MRP_PLANNING_CODE]="Not planned","accurate",
IIF([INVENTORY_ITEM_STATUS_CODE]="SrvcOnly"OR[INVENTORY_ITEM_STATUS_CODE]="Inactive"
AND[MRP_PLANNING_CODE]="Not planned","accurate",
IIF([INVENTORY_ITEM_STATUS_CODE]="ContrldRel"OR[INVENTORY_ITEM_STATUS_CODE]="Relsd Item"OR[INVENTORY_ITEM_STATUS_CODE]="Relsd SKU"
OR[INVENTORY_ITEM_STATUS_CODE]="PhsingOut"AND[MRP_PLANNING_CODE]="MRP and MPP planning","accurate",
IIF([INVENTORY_ITEM_STATUS_CODE]="Unreleased"AND[ITEM_TYPE]="SA"AND[MRP_PLANNING_CODE]="MRP and MPP planning","accurate",
IIF([INVENTORY_ITEM_STATUS_CODE]="Unreleased"AND[ITEM_TYPE]="PUR"AND[MRP_PLANNING_CODE]="Not planned","accurate","not accurate")))))
I also tried.
MRP Method Accurate:IIF([ITEM_TYPE]="PH"AND[MRP_PLANNING_CODE]="Not planned","accurate",
IIF([INVENTORY_ITEM_STATUS_CODE] IN("SrvcOnly","Inactive")AND[MRP_PLANNING_CODE]="Not planned","accurate",
IIF([INVENTORY_ITEM_STATUS_CODE] IN("ContrldRel","Relsd Item","Relsd SKU","PhsingOut")AND[MRP_PLANNING_CODE]="MRP and MPP planning","accurate",
IIF([INVENTORY_ITEM_STATUS_CODE]="Unreleased"AND[ITEM_TYPE]="SA"AND[MRP_PLANNING_CODE]="MRP and MPP planning","accurate",
IIF([INVENTORY_ITEM_STATUS_CODE]="Unreleased"AND[ITEM_TYPE]="PUR"AND[MRP_PLANNING_CODE]="Not planned","accurate","not accurate")))))
but is having the error Sytax error (missing operator) in query expression 'MRP Method Complete'.

how about limiting your code to just one iif:
MRP Method Accurate:
IIF( ([ITEM_TYPE]="PH" AND [MRP_PLANNING_CODE]="Not planned")
or ([INVENTORY_ITEM_STATUS_CODE]="SrvcOnly"OR[INVENTORY_ITEM_STATUS_CODE]="Inactive" AND[MRP_PLANNING_CODE]="Not planned")
or ([INVENTORY_ITEM_STATUS_CODE]="ContrldRel"OR[INVENTORY_ITEM_STATUS_CODE]="Relsd Item"OR[INVENTORY_ITEM_STATUS_CODE]="Relsd SKU" OR[INVENTORY_ITEM_STATUS_CODE]="PhsingOut"AND[MRP_PLANNING_CODE]="MRP and MPP planning")
or ([INVENTORY_ITEM_STATUS_CODE]="Unreleased"AND[ITEM_TYPE]="SA"AND[MRP_PLANNING_CODE]="MRP and MPP planning")
or ([INVENTORY_ITEM_STATUS_CODE]="Unreleased"AND[ITEM_TYPE]="PUR"AND[MRP_PLANNING_CODE]="Not planned")
,"accurate"
,"not accurate")
If you want to find out which piece is passing the test then make this 5 columns.
IIF( ([ITEM_TYPE]="PH" AND [MRP_PLANNING_CODE]="Not planned"),1,0)
,iif([INVENTORY_ITEM_STATUS_CODE]="SrvcOnly"OR[INVENTORY_ITEM_STATUS_CODE]="Inactive" AND[MRP_PLANNING_CODE]="Not planned"),1,0)
,iif([INVENTORY_ITEM_STATUS_CODE]="ContrldRel"OR[INVENTORY_ITEM_STATUS_CODE]="Relsd Item"OR[INVENTORY_ITEM_STATUS_CODE]="Relsd SKU" ),1,0)
,iif([INVENTORY_ITEM_STATUS_CODE]="PhsingOut"AND[MRP_PLANNING_CODE]="MRP and MPP planning"),1,0)
,iif([INVENTORY_ITEM_STATUS_CODE]="Unreleased"AND[ITEM_TYPE]="SA"AND[MRP_PLANNING_CODE]="MRP and MPP planning"),1,0)
,iif(([INVENTORY_ITEM_STATUS_CODE]="Unreleased"AND[ITEM_TYPE]="PUR"AND[MRP_PLANNING_CODE]="Not planned")),1,0)
Name them appropriately.
Finally add another column
iif(Test1+...+testN >0, "accurate","not accurate")

Related

How to conditionally return specific value with another in JSONPath?

I've got an object like this one:
{
"content": {
"iteration_size": 1
}
}
I need a JSONPath which returns null if the value of next_item is exactly 1, or the value of iteration_size otherwise. So the above should return null and "iteration_size": 2 should return 2. Is this possible in JSONPath?
I've tried variations on $.content[?(#.iteration_size == 1)].iteration_size, but the two online evaluators I've tried even disagree on the results of several of my attempts.
The use case is the AWS Batch API, where the array size must be either null or a number between 2 and 10,000.
AWS Support suggested that this was not possible, and that I should instead use a branch in the step function. I ended up replacing this:
.next(batch_submit_job)
[…]
with this:
.next(
aws_stepfunctions.Choice(self, "check_maybe_array")
.when(
aws_stepfunctions.Condition.number_equals("$.content.iteration_size", 1),
single_batch_submit_job,
)
.otherwise(array_batch_submit_job)
.afterwards()
)
where only array_batch_submit_job has an array_size. Note how the rest of the step function ended up wrapped inside the last next() call rather than at the top level.

SSRS REPORT BUILDER, Comparing two diffrent data sets in one Tablix, Expression

I have two datasets and want to compare them in an expression.
I would like to do something like this:
=iif(Fields!Grade.Value = "ONGRADE" > LookupSet(Fields!Grade.Value = "ONGRADE", Fields!grade.Value = "ONGRADE" , Fields!grade.Value = "ONGRADE", "Previous3Week"), "UP" ,"DOWN")
This currently returns "Error" within the "ONGRADE" row.
you need to bind your component with one of the datasets and then accordingly you can write following expression :
=iif(Fields!grade.Value > (Fields!grade.Value, "ONGRADE_DataSet2") , "UP", "DOWN")
in this example, the component is binded with the first dataset and the second dataset is getting referred.
This may help.

Check and print occurrences of an array of string in a dataset in Python

I want to check if an array of strings occur in a dataset and print those rows where the string array elements occur.
rareTitles = {"Capt", "Col", "Countess", "Don", "Dr", "Jonkheer", "Lady",
"Major", "Mlle", "Mme", "Ms", "Rev", "Sir"}
dataset[rareTitles in (dataset['Title'])]
I am getting following error:
TypeError: unhashable type: 'set'
First of all, I think the comparison should go the other way around - you look for a dataset['Title'], that contains string from rareTitles.
You can use str attribute of a pandas DataSeries, which allows as to use string methods, like contains. As this method accepts also a pattern as a regular expression, you can put as an argument something like 'Capt|Col...'. To join all elements of a set you can use str.join() method.
So the solution would be
dataset[dataset['Title'].str.contains('|'.join(rareTitles))]
Link to documentation: pandas.Series.str.contains

If a key has a value then print the value ruby

I'm trying to only put value of the key self only if the key escalation_policies has a value. This is an example a schedule that doesn't have an escalation policy hence I don't want the value for the key self
{"schedules"=>
[{"id"=>"0000000",
"type"=>"schedule",
"summary"=>"-PROD-",
"self"=>"https://api.pagerduty.com/schedules/",
"html_url"=>"https://pagerduty.com/schedules/",
"name"=>"-PROD-",
"time_zone"=>"America/",
"description"=>nil,
"privilege"=>nil,
"users"=>
[{"id"=>"0000000",
"type"=>"user_reference",
"summary"=>"DOo Kkkk",
"self"=>"https://api.pagerduty.com/users/",
"html_url"=>"https://target.pagerduty.com/users/"}],
"escalation_policies"=>[],
"teams"=>[]},
}
My code to conquer this challenge is:
somefile = File.open("Schedule_Api.txt", "a+")
jdoc.fetch("schedules").each do |schedule|
somefile.puts schedule["self"] if schedule["escalation_policies"].exists? == true
end
somefile.close
This variable jdoc is the curl for the website. And this is the result I get from this is undefined methodexists?' for []:Array (NoMethodError). Is there another alternative to this then the methodexists?`. Any help will be helpful! Thank you!
.exists? is a method from ActiveRecord, not on Array.
If you want to test for empty arrays, you probably want to do
somefile.puts schedule["self"] unless schedule["escalation_policies"].empty?
If you want to test for any value at all, just doing
somefile.puts schedule["self"] if schedule["escalation_policies"]
should work
Try:
if schedule.has_key?("escalation_policies")
You could also test:
if schedule["escalation_policies"]
which would return false not only if the key does not exist, but also if it does exist, and its corresponding value is nil.
If the absence of values will always be represented by an empty array ([]), then instead you can use schedule["escalation_policies"].empty? as mentioned by Rick Sullivan in his answer, or schedule["escalation_policies"].any? to test for an array size > 0.

Conf/Messages Choice in Play! + Scala

I run the sample code in play 2.2 "comuputer-database-jpa"
In the Conf/Messages
# Messages
computers.list.title={0,choice,0#No computers|1#One computer|1<{0,number,integer} computers} found
I want to used this conditional messages in my error messages to make my error message as dynamic as possible. In my code say that i'm passing 2 parameters and 1 of it is the message id.
#Messages(messageId,errors(1).getOrElse(""),errors(2).getOrElse(""))
equivalent to
#Messages(error.format,FIRST NAME)
can also be
#Messages(error.format,EMAIL)
How can i use the conditional conf/messages in my code? I tried some using the sample and an error occurred.
Code:
error.format = Enter {0,choice,FIRST NAME#{0} in half-width alphanumeric|EMAIL#{0} in valid format.}
What am i doing wrong?
The below code will yield what you are looking for
//html<br/>
#Messages("error.format",2, "name error","email error")
Number 2 in the example above will show the message "EMAIL in valid format". if you change it to 1 it will show the message "FIRST NAME in half-width alphanumeric"
//messages<br/>
error.format = Enter {0,choice,1#FIRST NAME in half-width alphanumeric|2#EMAIL in valid format.}