Defining a value based on multiple conditions
Use nested IfThenElse functions with And, Equal, Greater and Lesser functions to define the value of an element based on several conditions.
Before you begin
About this task
In this example, you have a JSON file containing a list of items with their ID and the number
of items in stock. You want to create a CSV output with the item ID and a status
related to the number of items in stock: out of stock if the
number is 0, low stock if the number is between 1 and 99, and
in stock if it is 100 or above. You can use the following
JSON as
input:
{
"items": [
{
"id" : 654981,
"stock": 43
},
{
"id" : 698624,
"stock": 295
},
{
"id" : 149875,
"stock": 0
},
{
"id" : 698763,
"stock": 100
},
{
"id" : 856231,
"stock": 15
},
{
"id" : 789354,
"stock": 457
}
]
}
You can use the following CSV sample to create your output
structure:
itemId,stockStatus
Procedure
Results
You can use the Test Run feature to see
the result. In this example, the following output is returned:
itemId,stockStatus
654981,low stock
698624,in stock
149875,out of stock
698763,in stock
856231,low stock
789354,in stock