{
"name": "UpdateArray",
"properties": {
"activities": [
{
"name": "Set variable1",
"type": "SetVariable",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"variableName": "Inter",
"value": {
"value": "@take(pipeline().parameters.IA,int(pipeline().parameters.ElementNbr))",
"type": "Expression"
}
}
},
{
"name": "ForEach1",
"type": "ForEach",
"dependsOn": [
{
"activity": "Set variable1",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"items": {
"value": "@variables('Inter')",
"type": "Expression"
},
"isSequential": true,
"activities": [
{
"name": "Append variable1",
"type": "AppendVariable",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"variableName": "Final",
"value": {
"value": "@item()",
"type": "Expression"
}
}
}
]
}
},
{
"name": "Append variable2",
"type": "AppendVariable",
"dependsOn": [
{
"activity": "ForEach1",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"variableName": "Final",
"value": {
"value": "@pipeline().parameters.IS",
"type": "Expression"
}
}
},
{
"name": "Set variable2",
"type": "SetVariable",
"dependsOn": [
{
"activity": "Append variable2",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"variableName": "Inter",
"value": {
"value": "@skip(pipeline().parameters.IA,add(int(pipeline().parameters.ElementNbr),1))",
"type": "Expression"
}
}
},
{
"name": "ForEach2",
"type": "ForEach",
"dependsOn": [
{
"activity": "Set variable2",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"items": {
"value": "@variables('Inter')",
"type": "Expression"
},
"isSequential": true,
"activities": [
{
"name": "Append variable1_copy1",
"type": "AppendVariable",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"variableName": "Final",
"value": {
"value": "@item()",
"type": "Expression"
}
}
}
]
}
}
],
"parameters": {
"IA": {
"type": "array",
"defaultValue": [
1,
2,
3,
4,
5,
9
]
},
"IS": {
"type": "string",
"defaultValue": "6"
},
"ElementNbr": {
"type": "string",
"defaultValue": "3"
}
},
"variables": {
"Inter": {
"type": "Array"
},
"Final": {
"type": "Array"
}
},
"annotations": []
}
}
How to update Nth Element of an array
HI,
Is it possible to update/replace the nth element of an array
input =[1,2,3,4]
Update 3rd element from 3 to 5
Output=[1,2,5,4]]
Azure Synapse Analytics
Azure Data Factory
2 answers
Sort by: Most helpful
-
Nandan Hegde 36,146 Reputation points MVP Volunteer Moderator
2023-02-22T14:49:53.23+00:00 -
KranthiPakala-MSFT 46,642 Reputation points Microsoft Employee Moderator
2023-02-24T22:51:23.2333333+00:00 Hi @Priya Jha ,
Thanks for using Microsoft Q&A forum and posting your query.
I would go with Nandan Hegdes solution if you are referring to regular pipeline expressions. In case if you are using Mapping data flows and would like to achieve your requirement then you can use MapIndex function in Expression builder.
Here is a sample:
Hope this helps.
Please don’t forget to
Accept Answer
andYes
for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members.