CellService
using Skipcheck.Tm1.Client.Services;Used in the walkthroughs Read and write cells, Run a process and read its result.
Cell writes to a cube, by coordinates. Cells are given as Tuples.Of maps of
dimension to element; reading is through cellsets (CellsetService), and writing
into one by ordinal is there too.
Values are numbers for numeric cells and text for string cells; null clears a
cell. TM1 (11.8) refuses a write to a consolidated cell (400,
CubeCellWriteStatusElementIsConsolidated): it doesn't spread; write the leaves.
tm1.Update takes several cells, but TM1 (11.8) writes only the first, so
UpdateAsync takes one; UpdateCellsAsync writes many in one request.
Write one cell, given an element for every dimension of the cube, in order:
// The cell: an element for every dimension of the cube, in the cube's order
var cell = new Dictionary<string, string>
{
["Version"] = "Budget",
["Region"] = "North",
["Month"] = "Jan",
["Measure"] = "Revenue",
};
await tm1.Cells.UpdateAsync("Sales", cell, 1200);
Write many cells in one request:
// A budget for North, one value per month, written in one request
var budget = new Dictionary<string, int>
{
["Jan"] = 1200,
["Feb"] = 1350,
["Mar"] = 1100,
};
var updates = budget
.Select(month =>
{
var cell = new Dictionary<string, string>
{
["Version"] = "Budget",
["Region"] = "North",
["Month"] = month.Key,
["Measure"] = "Revenue",
};
return CubeUpdatePatch.Builder().BindTuple(Tuples.Of(cell)).Value(month.Value).Build();
})
.ToList();
await tm1.Cells.UpdateCellsAsync("Sales", updates);
Members
CellService constructor | A service that sends its requests through session. |
UpdateAsync | Writes one value to a cell; tuple is dimension to element, as for Tuples.Of; null clears the cell. |
UpdateCellsAsync | Writes many cells, each its own value, in one request. |
UpdateCellsAsync | tm1.UpdateCells with an order. |
CellService
constructorCellService(Tm1Session session)A service that sends its requests through session.
UpdateAsync
Task UpdateAsync(string cube, IReadOnlyDictionary<string, string> tuple, object? value, CancellationToken cancellationToken = default)tm1.Update: writes one value to a cell; tuple is dimension to
element, as for Tuples.Of; null clears the cell.
TM1 REST Action Cube/Update Navigation CellDescriptor/Tuple
UpdateCellsAsync
Task UpdateCellsAsync(string cube, IReadOnlyList<CubeUpdatePatch> updates, CancellationToken cancellationToken = default)tm1.UpdateCells: writes many cells, each its own value, in one request. Needs schema
11.0.0. TM1 (11.8) requires a Tuple and a Value in every update (400 otherwise). The
patch can also bind a ReferenceCube and ReferenceCell; on a leaf they didn't change
what's written, and they don't copy that cell's value.
TM1 REST Action Cube/UpdateCells Navigation CubeUpdate/Tuple Navigation CubeUpdate/ReferenceCube Navigation CubeUpdate/ReferenceCell
UpdateCellsAsync
Task UpdateCellsAsync(string cube, IReadOnlyList<CubeUpdatePatch> updates, UpdateOrder order, CancellationToken cancellationToken = default)tm1.UpdateCells with an order: ByLevel writes leaves before the consolidations
above them, so a spread to a consolidation isn't overwritten. Needs schema 11.0.0.
TM1 REST Action Cube/UpdateCells Navigation CubeUpdate/Tuple Navigation CubeUpdate/ReferenceCube Navigation CubeUpdate/ReferenceCell