# Clone a measure

Clone a measure by using the [CloneMeasure method](https://help.qlik.com/en-US/sense-developer/May2025/Subsystems/EngineJSONAPI/Content/service-doc-clonemeasure.htm).

## Example

[](https://help.qlik.com/en-US/sense-developer/Subsystems/EngineAPI/Content/Sense_EngineAPI/WorkingWithAppsAndVisualizations/CreateVisualizations/clone-measure.htm)

#### The goal is to clone a measure.

The handle of the app is 1.

1. Create an engine session list in order to list the measures in the app (qMeasureListDef.

The client sends:

```
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "CreateObject",
  "handle": 1,
  "params": [
    {
      "qInfo": {
        "qId": "SE01",
        "qType": "SessionLists"
      },
      "qAppObjectListDef": {
        "qType": "sheet",
        "qData": {
          "id": "/qInfo/qId"
        }
      },
      "qDimensionListDef": {
        "qType": "Dimension",
        "qData": {}
      },
      "qMeasureListDef": {
        "qType": "Measure",
        "qData": {}
      }
    }
  ]
}
```

The engine returns:

```
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "qReturn": {
      "qType": "GenericObject",
      "qHandle": 2
    },
    "qInfo": {
      "qId": "SE01",
      "qType": "SessionLists"
    }
  },
  "change": [
    2
  ]
}
```

The session list is created and has 2 as a handle.

2. Create a measure with the identifier Measure01.

The client sends:

```
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "CreateMeasure",
  "handle": 1,
  "params": [
    {
      "qInfo": {
        "qId": "Measure01",
        "qType": "Measure"
      },
      "qMeasure": {
        "qLabel": "measure label",
        "qDef": "Country"
      }
    }
  ]
}
```

The engine returns:

```
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "qReturn": {
      "qType": "GenericMeasure",
      "qHandle": 3
    },
    "qInfo": {
      "qId": "Measure01",
      "qType": "Measure"
    }
  },
  "change": [
    3
  ]
}
```

The measure Measure01 is created and has 3 as a handle.

3. Clone the measure Measure01.

The client sends:

```
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "CloneMeasure",
  "handle": 1,
  "params": [
    "Measure01"
  ]
}
```

The engine returns:

{ "jsonrpc": "2.0", "id": 3, "result": { "qCloneId": "75664150-95d9-49cf-ac02-bbfe94cfacdb" } }

The clone is created. The identifier (set by the engine) of the clone is 75664150-95d9-49cf-ac02-bbfe94cfacdb.

4. Get the handle of the clone. 75664150-95d9-49cf-ac02-bbfe94cfacdb is the identifier of the clone.

The client sends:

{ "jsonrpc": "2.0", "id": 4, "method": "GetMeasure", "handle": 1, "params": [ "75664150-95d9-49cf-ac02-bbfe94cfacdb" ] }

The engine returns:

{ "jsonrpc": "2.0", "id": 4, "result": { "qReturn": { "qType": "GenericMeasure", "qHandle": 4 } } }

The handle of the clone is 4.

5. Get the properties of the clone. The handle of the request is 4 because the clone uses 4 as a handle.

The client sends:

{ "jsonrpc": "2.0", "id": 5, "method": "GetProperties", "handle": 4, "params": [] }

The engine returns:

{ "jsonrpc": "2.0", "id": 5, "result": { "qProp": { "qInfo": { "qId": "75664150-95d9-49cf-ac02-bbfe94cfacdb", "qType": "Measure" }, "qMeasure": { "qLabel": "measure label", "qDef": "Country", "qGrouping": "N", "qExpressions": [], "qActiveExpression": 0 }, "qMetaDef": {} } } }

The clone is identical to the original measure.

6. Check that the clone is added to the session list. The handle of the request is 2 because the session list uses 2 as a handle.

The client sends:

{ "jsonrpc": "2.0", "id": 6, "method": "GetLayout", "handle": 2, "params": [] }

The engine returns:

{ "jsonrpc": "2.0", "id": 6, "result": { "qLayout": { "qInfo": { "qId": "SE01", "qType": "SessionLists" }, "qSelectionInfo": {}, "qAppObjectList": { "qItems": [] }, "qDimensionList": { "qItems": [] }, "qMeasureList": { "qItems": [ { "qInfo": { "qId": "Measure01", "qType": "Measure" }, "qData": {} }, { "qInfo": { "qId": "75664150-95d9-49cf-ac02-bbfe94cfacdb", "qType": "Measure" }, "qData": {} } ] } } } }

The session list contains the measure Measure01 and the clone 75664150-95d9-49cf-ac02-bbfe94cfacdb.