Glossary · Data

ValueRank

In OPC UA, ValueRank is a Variable or VariableType attribute declaring the dimensionality of the value. Minus one means a scalar, one or more means that exact number of array dimensions, zero means one or more dimensions, minus two means any rank, and minus three means either a scalar or a one-dimensional array.

The five defined values

The negative constants are the ones people misread. Scalar is minus one. Any is minus two, meaning the server accepts any rank. ScalarOrOneDimension is minus three. Zero is OneOrMoreDimensions, so it is an array of unspecified rank, not a scalar. Any positive integer is the exact rank: one for a vector, two for a matrix, three for a cube. The value is fixed by the model, so a client can read it once at startup and cache it.

How it pairs with ArrayDimensions

ValueRank gives the number of dimensions; ArrayDimensions optionally gives their lengths. If ValueRank is one, ArrayDimensions is either omitted or a single-element array whose value is the fixed length, with zero meaning unspecified. If ValueRank is two, ArrayDimensions has two entries. The pair together tells you the exact shape a Write must produce and the exact shape a Read will return, which is what IndexRange then addresses into.

Why it breaks writes

A server validates the incoming Variant against DataType, ValueRank and ArrayDimensions. Sending a scalar to a node with ValueRank one, or a one-element array to a node with ValueRank minus one, is a rank mismatch and returns BadTypeMismatch even though the element type is correct. This is common with PLC servers where a single-element array of Bool models a coil, and with SDK helpers that quietly wrap a value in a list.

Example

Reading ValueRank and ArrayDimensions before writing, so the Variant is built with the right shape

Node: ns=3;s=Recipe.SetpointArray
  DataType        = Double (i=11)
  ValueRank       = 1        -> one-dimensional array
  ArrayDimensions = [8]      -> exactly 8 elements

Write must send a Double[8]. A Double scalar returns BadTypeMismatch;
a Double[5] returns BadTypeMismatch or BadOutOfRange depending on the server.
The mistake people make: Reading ValueRank as zero and treating it as scalar. Zero is OneOrMoreDimensions, the array case; scalar is minus one. Client code that tests for a falsy value here inverts the meaning and builds every Variant the wrong shape.

Defined in: Part 3 - Address Space Model, Variable attributes.

Status codes you will meet

Last verified 7 September 2026 against OPC UA 1.05.07. OPC UA Connect is an educational resource and is not affiliated with the OPC Foundation.

Free download
OPC UA Server Acceptance Test Pack
A 40-check acceptance test you run against a vendor's server before commissioning sign-off. Weighted scoring, three hard gates, and a one-page verdict for the supplier meeting.
Get the free test pack →
Free, no course, no login