---
title: USING and parameters
summary: Result-wide unit conversion with USING LENGTH_UNIT, AREA_UNIT, VOLUME_UNIT, MASS_UNIT and TEMPERATURE_UNIT, the original_* fields, and query parameters ($name) with their binding rules.
order: 70
see-also: [reference/bql/unit, reference/bql/where, reference/bql/ast, how-to/query/use-query-parameters]
---

# USING and parameters

`USING` is the last clause of a query and sets the output unit per dimension for every value in the result. Parameters (`$name`) are values supplied when the query runs; they are described on this page because both are about the query's run-time context rather than its logic.

## USING {#using}

```text {#using-syntax}
USING LENGTH_UNIT = <unit> AREA_UNIT = <unit> VOLUME_UNIT = <unit> MASS_UNIT = <unit> TEMPERATURE_UNIT = <unit>
```

Each sub-clause is optional and appears at most once; they may come in any order, and whitespace around `=` is allowed. The units are those of [[bql:unit#units]], listed below. A dimension without a sub-clause keeps the model's unit.

```bql {#using-basic}
GET qid, quantity.Qto_WallBaseQuantities.NetSideArea, quantity.Qto_WallBaseQuantities.Length
WHERE type = IFCWALL
USING LENGTH_UNIT = mm AREA_UNIT = m2
```

```bql {#using-order}
GET qid, quantity.*.NetVolume, quantity.*.GrossWeight WHERE type = IFCBEAM USING MASS_UNIT = kg VOLUME_UNIT = m3
```

### Units {#units}

| Sub-clause | Units |
|---|---|
| `LENGTH_UNIT` | `mm` `cm` `dm` `m` `km` `in` `ft` `yd` `mi` |
| `AREA_UNIT` | `mm2` `cm2` `dm2` `m2` `km2` `in2` `ft2` `yd2` `ac` `mi2` |
| `VOLUME_UNIT` | `mm3` `cm3` `dm3` `m3` `in3` `ft3` `yd3` `l` |
| `MASS_UNIT` | `mg` `cg` `g` `kg` |
| `TEMPERATURE_UNIT` | `dc` |

These are all the units of the grammar, the same ones [[bql:unit]] and unit literals take.

### What is converted {#scope}

Every value with a unit of the given dimension: properties and quantities, calculated values, arithmetic columns, and the member values of list, enumerated and bounded properties. A `GET` item with its own `UNIT` clause is converted to that unit instead and ignores `USING` for that item.

### Result annotation {#result}

A value `USING` converts keeps its metadata and gains the original: `unit` and `symbol` show the target unit, and `original_value`, `original_unit` and `original_symbol` hold what the model stored. A value whose unit is already the target is returned unchanged, without `original_*` fields.

```json {#using-result}
{"name": "NetSideArea", "type": "DOUBLE", "value": 12.5, "unit": "SQUARED_METER", "symbol": "m²",
 "original_value": 12500000.0, "original_unit": "SQUARED_MILLI_METER", "original_symbol": "mm²"}
```

The internal sentinel names (`LENGTH_NONE`, `AREA_NONE`, …) are not units; using one is a validation error.

## Parameters {#parameters}

`$name` marks a value that is supplied when the query runs. The query is stored once and bound many times — with the viewer's selection, with a slider, or with a `parameters` object in the query call.

```bql {#parameter-basic}
GET qid, attribute.Name WHERE type = IFCSLAB AND calculated.quantity.volume > $minVolume
```

```bql {#parameter-selection}
GET qid, attribute.Name, buildingStorey.attribute.Name WHERE qid IN $selection
```

### Positions {#positions}

A parameter can stand in for:

| Position | Example |
|---|---|
| The right-hand side of `=`, `!=`, `<`, `<=`, `>`, `>=` | `aabb.height > $min` |
| A list: `IN $p`, `NOT IN $p`, `type IN $types`, `qid IN $selection` | `property.*.FireRating IN $ratings` |
| Both ends or the whole range of `BETWEEN` | `BETWEEN $lo AND $hi`, `BETWEEN($lo, $hi)`, `BETWEEN $range` |
| The string of `CONTAINS`, `STARTS_WITH`, `ENDS_WITH`, `MATCHES_REGEX`, `MATCHES`, `CS =`, `CS !=`, `LENGTH` | `attribute.Name CONTAINS $text` |
| The argument of the spatial and semantic functions | `geometry:touches($selected)`, `CLASHES_WITH($selected)`, `sem:providesBoundariesFor($spaces)` |

### Binding {#binding}

The query call carries `parameters`, a JSON object from name to value: a number, string or boolean for a scalar position, an array for a list position (`type IN $types` takes an array of class-name strings, `qid IN $selection` an array of qid strings), a two-element numeric array for `BETWEEN $range`. Binding is structural — values are inserted into the parsed query, never into its text — so a value cannot change the query's syntax.

When a `parameters` object is supplied, every parameter in the query must be bound: a missing one raises [[error:BimWorksQueryError.MISSING_PARAMETER]], a value of the wrong shape [[error:BimWorksQueryError.PARAMETER_TYPE_MISMATCH]]. Without a `parameters` object the query runs unbound and an unbound parameter matches nothing; that mode exists for clients that substitute values in the [[bql:ast|AST]] themselves.

The JavaScript SDK passes parameters with the query, `client.bim.query(models, query, false, false, {minVolume: 2})`, where `QueryHelper.toParameterValues` turns a `QidSet` into the array form; in Java they go through the client's request API. The .NET SDK, the PHP client and the HTTP [[openapi:Query]] operation have no `parameters` field yet ([[page:how-to/query/use-query-parameters]]). The `QueryParameterInfo` task reports, per parameter, the kind of value it needs and the value domain of its feature (minimum, maximum and count for numbers, the distinct values for strings), which is what the parameter panel in the UI uses to build sliders and pick-lists.

### In stored queries {#stored}

In the UI, parameters belong to stored query actions: the user gets a panel with one control per parameter. The validator marks every `$name` with an information message saying a value is supplied at run time, so a forgotten parameter is visible in the editor.

## Used in {#used-in}

- [[page:tutorials/bql/units-and-parameters]] — `USING` and `$name`.
- [[page:how-to/query/use-query-parameters]] — binding parameters from an SDK.
