How to increment counter in Gatling?


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.