-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/TabularEditor/TabularEditor…
- Loading branch information
Showing
25 changed files
with
219 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
common/CSharpScripts/Beginner/script-create-field-parameter.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
uid: create-field-parameter | ||
title: Create Field Parameter | ||
author: Daniel Otykier | ||
updated: 2024-01-27 | ||
applies_to: | ||
versions: | ||
- version: 2.x | ||
- version: 3.x | ||
--- | ||
# Create Field Parameters in | ||
|
||
## Script Purpose | ||
If you want to create field parameters in a Power BI model using Tabular Editor or in a Direct Lake model. | ||
|
||
> [!TIP] | ||
> Want to see the script in action, check out this [Guy in a Cube video](https://www.youtube.com/watch?v=Cg6zRhwF-Ro) where Patrick LeBlanc explains how to use it step by step. | ||
|
||
## Script | ||
|
||
### Select Columns or Measures to create a field parameter table | ||
```csharp | ||
// Before running the script, select the measures or columns that you | ||
// would like to use as field parameters (hold down CTRL to select multiple | ||
// objects). Also, you may change the name of the field parameter table | ||
// below. NOTE: If used against Power BI Desktop, you must enable unsupported | ||
// features under File > Preferences (TE2) or Tools > Preferences (TE3). | ||
var name = "Parameter"; | ||
|
||
if(Selected.Columns.Count == 0 && Selected.Measures.Count == 0) throw new Exception("No columns or measures selected!"); | ||
|
||
// Construct the DAX for the calculated table based on the current selection: | ||
var objects = Selected.Columns.Any() ? Selected.Columns.Cast<ITabularTableObject>() : Selected.Measures; | ||
var dax = "{\n " + string.Join(",\n ", objects.Select((c,i) => string.Format("(\"{0}\", NAMEOF('{1}'[{0}]), {2})", c.Name, c.Table.Name, i))) + "\n}"; | ||
|
||
// Add the calculated table to the model: | ||
var table = Model.AddCalculatedTable(name, dax); | ||
|
||
// In TE2 columns are not created automatically from a DAX expression, so | ||
// we will have to add them manually: | ||
var te2 = table.Columns.Count == 0; | ||
var nameColumn = te2 ? table.AddCalculatedTableColumn(name, "[Value1]") : table.Columns["Value1"] as CalculatedTableColumn; | ||
var fieldColumn = te2 ? table.AddCalculatedTableColumn(name + " Fields", "[Value2]") : table.Columns["Value2"] as CalculatedTableColumn; | ||
var orderColumn = te2 ? table.AddCalculatedTableColumn(name + " Order", "[Value3]") : table.Columns["Value3"] as CalculatedTableColumn; | ||
|
||
if(!te2) { | ||
// Rename the columns that were added automatically in TE3: | ||
nameColumn.IsNameInferred = false; | ||
nameColumn.Name = name; | ||
fieldColumn.IsNameInferred = false; | ||
fieldColumn.Name = name + " Fields"; | ||
orderColumn.IsNameInferred = false; | ||
orderColumn.Name = name + " Order"; | ||
} | ||
// Set remaining properties for field parameters to work | ||
// See: https://twitter.com/markbdi/status/1526558841172893696 | ||
nameColumn.SortByColumn = orderColumn; | ||
nameColumn.GroupByColumns.Add(fieldColumn); | ||
fieldColumn.SortByColumn = orderColumn; | ||
fieldColumn.SetExtendedProperty("ParameterMetadata", "{\"version\":3,\"kind\":2}", ExtendedPropertyType.Json); | ||
fieldColumn.IsHidden = true; | ||
orderColumn.IsHidden = true; | ||
``` | ||
### Explanation | ||
Before running the script the user has to select the measures or columns in the TOM Explorer they wish to have in their field parameter table. | ||
The selected objects are then inserted into a calculated table which is then configured as a field parameter table automatically. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
uid: pivot-grid | ||
title: Pivot Grids | ||
author: Morten Lønskov | ||
updated: 2024-01-22 | ||
applies_to: | ||
editions: | ||
- edition: Desktop | ||
- edition: Business | ||
- edition: Enterprise | ||
--- | ||
# Pivot Grids | ||
|
||
After adding or editing DAX measures in a model, it is common for model developers to test these measures. Traditionally, this was done using client tools such as Excel or Power BI. With Tabular Editor 3, you can use **Pivot Grids** which behave much like the famous PivotTables of Excel. The Pivot Grid lets you quickly create summarized views of the data in your model, allowing you to test the behavior of your DAX measures when filtering and slicing by various columns and hierarchies. | ||
|
||
To create a new Pivot Grid, use the **File > New > Pivot Grid** option. From here, you can either drag measures, columns and hierarchies directly from the TOM Explorer into the grid, or you can use the **Pivot Grid > Show fields** menu option to display a popup list of all fields that can be dragged into the Pivot Grid (see screenshot below). | ||
|
||
![Show Fields Pivot](~/images/show-fields-pivot.png) | ||
|
||
As fields are dragged into the Pivot Grid, Tabular Editor generates MDX queries that are sent to Analysis Services, to display the resulting data. In this regard, the behavior is very similar to Pivot Tables in Excel. You can rearrange fields in the Pivot Grid by dragging and dropping, and there are various right-click menu options available for customizing how the data is displayed. | ||
|
||
> [!IMPORTANT] | ||
> Since Pivot Grids relies on the Analysis Services engine for query execution, this feature is not available when working in offline mode (such as when editing a model.bim file in Tabular Editor, without a connection to a workspace database). | ||
![Customizing Pivot Grids](../images/customizing-pivot-grids.png) | ||
|
||
The Pivot Grid is automatically refreshed when a change is made to the model or a refresh operation finishes. You can toggle this auto-refresh capability within the **Pivot Grid** menu. | ||
|
||
> [!Note] | ||
> The Pivot Grid currently does not work with [hidden fields](https://github.com/TabularEditor/TabularEditor3/issues/345). As a workaround, temporarily unhide the field and save the model, before dragging the field into the Pivot Grid. Moreover, the Pivot Grid only displays values on rows/columns [when at least one measure is present](https://github.com/TabularEditor/TabularEditor3/issues/776). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.