# Using apoc.do.when

**URL:** <https://community.neo4j.com/t/using-apoc-do-when/58363>\
**Category:** Neo4j Graph Platform\
**Tags:** migrated\
**Created:** [January 13, 2023, 9:10pm UTC](https://community.neo4j.com/t/using-apoc-do-when/58363 "2023-01-13T21:10:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thebird3](https://avatars.discourse-cdn.com/v4/letter/t/3da27b/32.png) [@thebird3](https://community.neo4j.com/u/thebird3)\
**Post date:** [January 13, 2023, 9:10pm UTC](https://community.neo4j.com/t/using-apoc-do-when/58363/1 "2023-01-13T21:10:36Z")

</div>

Not sure if this is the correct location for this question, but I am trying to use apoc.do.when with my neo4j version 5 instance. I have been trying to use the docs to create my query but for some reason one of my parameters is not being changed correctly in my query string and I am not sure why.

```auto
LOAD CSV WITH HEADERS FROM 'file:///pcs.csv' AS row
with row, row.left as left, row.left_type as left_type
CALL apoc.do.when(
  row.concept IS NOT NULL,
 'CREATE (n:left_type {id: left }) RETURN n AS node',
 'CREATE (c:Node{name:"C"}) RETURN c AS node',
 {left_type:left_type,left:left})
YIELD value
RETURN value.node AS node;

```

When I read in the rows of the csv some rows have a concept value and some don't. Based on this I want to create different nodes in the database. The condition is working and the "left" parameter is being correctly changed but left\_type is still called left\_type not the actual label it should be.

```auto
{
  "identity": 507,
  "labels": [
    "left_type"
  ],
  "properties": {
    "id": "1"
  },
  "elementId": "507"
}

```

Looks like this^

Any help would be useful

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [January 13, 2023, 10:12pm UTC](https://community.neo4j.com/t/using-apoc-do-when/58363/2 "2023-01-13T22:12:57Z")

</div>

You can not set a label with a variable. The 'left\_type' in your 'create ' statement is setting the label to 'left\_type'. If you want to set the label dynamically, you can use an apoc method to create the node and specify the label in the same procedure.

[https://neo4j.com/labs/apoc/4.1/overview/apoc.create/apoc.create.node/](https://neo4j.com/labs/apoc/4.1/overview/apoc.create/apoc.create.node/)

---

<div class="post-metadata">

**Author:** ![thebird3](https://avatars.discourse-cdn.com/v4/letter/t/3da27b/32.png) [@thebird3](https://community.neo4j.com/u/thebird3)\
**Post date:** [January 16, 2023, 12:32pm UTC](https://community.neo4j.com/t/using-apoc-do-when/58363/3 "2023-01-16T12:32:39Z")

</div>

Thanks so much for the response. I was misunderstanding how to use parameters. Figured it out with your suggestion.
