# How to increment counter in Gatling?

**URL:** https://community.gatling.io/t/how-to-increment-counter-in-gatling/6045
**Category:** Gatling (Open-Source)
**Created:** [April 2, 2021, 8:45pm UTC](https://community.gatling.io/t/how-to-increment-counter-in-gatling/6045 "2021-04-02T20:45:23Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Hareesh\_A](https://avatars.discourse-cdn.com/v4/letter/h/77aa72/32.png) [@Hareesh\_A](https://community.gatling.io/u/Hareesh_A)
#### Post date: [April 2, 2021, 8:45pm UTC](https://community.gatling.io/t/how-to-increment-counter-in-gatling/6045/1 "2021-04-02T20:45:23Z")

</div>

Hi

I am trying to implement a counter. I am calling a post service by iterating through list of ids and I need to check the status for each iteration and increment the counter variable when the status is 200. I am have below code snippet,

**def createData() = foreach("${userIdList}",“userId”){ exec(http(“file upload”).post("/compute-metaservice/datasets/${userId}/uploadFile") .formUpload(“File”,"./src/test/resources/data/Test.csv") .header(“content-type”,“multipart/form-data”) .check(status is 200)) }**

I need to add a if condition here something like **if(status is 200){counter++}**. Can someone please help on how I can implement this.
