Skip to content

Commit d80c8d1

Browse files
committed
Update with TE2 specific adaptations
1 parent 82ce09b commit d80c8d1

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

content/how-tos/scripting-ui-helpers.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var table = SelectTable(); // pick a table
3333
var column = SelectColumn(table.Columns); // pick from filtered columns
3434
var measure = SelectMeasure(); // pick a measure
3535
var obj = SelectObject<DataSource>(Model.DataSources); // generic selection
36-
var items = SelectObjects(collection); // multi-select
36+
var items = SelectObjects(collection); // multi-select (TE3 only)
3737
3838
// Evaluate DAX
3939
var result = EvaluateDax("COUNTROWS('Sales')"); // run DAX on connected model
@@ -107,7 +107,10 @@ catch
107107
}
108108
```
109109

110-
### Multi-select
110+
### Multi-select (Tabular Editor 3 only)
111+
112+
> [!NOTE]
113+
> `SelectObjects()` is only available in Tabular Editor 3. In Tabular Editor 2, use a single-select dialog in a loop or filter the selection before running the script.
111114
112115
`SelectObjects()` allows the user to pick multiple objects.
113116

content/how-tos/scripting-use-selected-object.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ var newMeasure = table.AddMeasure(
118118

119119
## Mixed selections
120120

121-
When you need to handle multiple object types from the selection, use `Selected.Objects` which returns all selected items as `ITabularNamedObject`.
121+
When you need to handle multiple object types from the selection, iterate `Selected` directly. The `Selected` variable itself implements `IEnumerable<ITabularNamedObject>`.
122122

123123
```csharp
124-
foreach (var obj in Selected.Objects)
124+
foreach (var obj in Selected)
125125
{
126126
if (obj is IDescriptionObject desc)
127127
desc.Description = "Reviewed on " + DateTime.Today.ToString("yyyy-MM-dd");

content/how-tos/scripting-work-with-expressions.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,19 @@ foreach (var col in Selected.Columns)
8989

9090
## The IExpressionObject interface
9191

92-
Objects that hold expressions implement `IExpressionObject`. Cast to the interface for generic code that works across measures, partitions, calculation items, etc.
92+
Objects that hold expressions implement `IExpressionObject`. In Tabular Editor 2, this interface provides only the `Expression` property. In Tabular Editor 3, it adds `GetExpression()`, `SetExpression()` and `GetExpressionProperties()` for working with multiple expression types on a single object.
9393

9494
```csharp
95-
// List all expression types on an object
95+
// Tabular Editor 2: use the Expression property directly
96+
measure.Expression = "SUM('Sales'[Amount])";
97+
string dax = measure.Expression;
98+
```
99+
100+
> [!NOTE]
101+
> The following `GetExpression`/`SetExpression` pattern is only available in Tabular Editor 3. In Tabular Editor 2, access the `Expression` property directly on the object.
102+
103+
```csharp
104+
// Tabular Editor 3 only: list all expression types on an object
96105
var exprObj = (IExpressionObject)measure;
97106
foreach (var prop in exprObj.GetExpressionProperties())
98107
{
@@ -106,7 +115,7 @@ exprObj.SetExpression(ExpressionProperty.Expression, "SUM('Sales'[Amount])");
106115
exprObj.SetExpression(ExpressionProperty.FormatStringExpression, "\"$#,##0.00\"");
107116
```
108117

109-
The `ExpressionProperty` enum includes:
118+
The `ExpressionProperty` enum (Tabular Editor 3 only) includes:
110119

111120
| Value | Used on |
112121
|---|---|

0 commit comments

Comments
 (0)