-
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.
* Updated note * Adjusted scripts in Macroactions to fit script library * Added scripts from MacroActions * Updated note on SymLink * Updated table groups script * Udpated MacroFile to fit script library * Name change for script files * Updates table groups script * Fixed uncomplete sentence * Fix script remove measures with outdatet method
- Loading branch information
Showing
10 changed files
with
204 additions
and
33 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
24 changes: 24 additions & 0 deletions
24
common/CSharpScripts/Beginner/script-create-measure-table.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,24 @@ | ||
--- | ||
uid: script-create-measure-table | ||
title: Create Measure Table | ||
author: Morten Lønskov | ||
updated: 2023-11-29 | ||
applies_to: | ||
versions: | ||
- version: 2.x | ||
- version: 3.x | ||
--- | ||
# Create Measure Table | ||
|
||
## Script Purpose | ||
The scripts creates a hidden measure table containing one hidden column | ||
|
||
|
||
## Script | ||
|
||
### Create Measure Table | ||
```csharp | ||
// Create a calculated table with a single column which is hidden: | ||
var table = Model.AddCalculatedTable("Model Measures", "{0}"); | ||
table.Columns[0].IsHidden = true; | ||
``` |
2 changes: 1 addition & 1 deletion
2
...inner/create-sum-measures-from-columns.md → ...cript-create-sum-measures-from-columns.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
55 changes: 55 additions & 0 deletions
55
common/CSharpScripts/Beginner/script-create-table-groups.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,55 @@ | ||
--- | ||
uid: script-create-table-groups | ||
title: Create Table Groups | ||
author: Morten Lønskov | ||
updated: 2023-11-29 | ||
applies_to: | ||
versions: | ||
- version: 3.x | ||
--- | ||
# Create Table Groups | ||
|
||
## Script Purpose | ||
This script creates default table groups within Tabular Editor 3. | ||
|
||
## Script | ||
|
||
### Script Title | ||
```csharp | ||
// Loop through all tables: | ||
foreach(var table in Model.Tables) | ||
{ | ||
if (table is CalculationGroupTable) | ||
{ | ||
table.TableGroup = "Calculation Groups"; | ||
} | ||
else if (!table.UsedInRelationships.Any() && table.Measures.Any(m => m.IsVisible)) | ||
{ | ||
// Tables containing visible measures, but no relationships to other tables | ||
table.TableGroup = "Measure Groups"; | ||
} | ||
else if (table.UsedInRelationships.All(r => r.FromTable == table) && table.UsedInRelationships.Any()) | ||
{ | ||
// Tables exclusively on the "many" side of relationships: | ||
table.TableGroup = "Facts"; | ||
} | ||
else if (!table.UsedInRelationships.Any() && table is CalculatedTable && !table.Measures.Any()) | ||
{ | ||
// Tables without any relationships, that are Calculated Tables and do not have measures: | ||
table.TableGroup = "Parameter Tables"; | ||
} | ||
else if (table.UsedInRelationships.Any(r => r.ToTable == table)) | ||
{ | ||
// Tables on the "one" side of relationships: | ||
table.TableGroup = "Dimensions"; | ||
} | ||
else | ||
{ | ||
// All other tables: | ||
table.TableGroup = "Misc"; | ||
} | ||
} | ||
``` | ||
### Explanation | ||
The scripts loops through all tables in the model assigning a table group according to specific properties. | ||
|
44 changes: 44 additions & 0 deletions
44
common/CSharpScripts/Beginner/script-format-numeric-measures.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,44 @@ | ||
--- | ||
uid: script-format-numeric-measures | ||
title: Format Numeric Measures | ||
author: Morten Lønskov | ||
updated: 2023-11-29 | ||
applies_to: | ||
versions: | ||
- version: 2.x | ||
- version: 3.x | ||
--- | ||
# Format Numeric Measures | ||
|
||
## Script Purpose | ||
Allows you to quickly set default format strings on the measures selected. | ||
|
||
<br></br> | ||
> [!NOTE] | ||
> The script uses certain naming standards so you might wish to adjust it to suit yours. | ||
<br></br> | ||
## Script | ||
|
||
### Script Title | ||
```csharp | ||
// This script is meant to format all measures with a default formatstring | ||
foreach (var ms in Selected.Measures) { | ||
//Don't set format string on hidden measures | ||
if (ms.IsHidden) continue; | ||
// If the format string is empty continue. | ||
if (!string.IsNullOrWhiteSpace(ms.FormatString)) continue; | ||
//If the data type is int set a whole number format string | ||
if (ms.DataType == DataType.Int64) ms.FormatString = "#,##0"; | ||
//If the datatype is double or decimal | ||
if (ms.DataType == DataType.Double || ms.DataType == DataType.Decimal) { | ||
//and the name contains # or QTY then set the format string to a whole number | ||
if (ms.Name.Contains("#") | ||
|| ms.Name.IndexOf("QTY", StringComparison.OrdinalIgnoreCase) >= 0) ms.FormatString = "#,##0"; | ||
//otherwise set it a decimal format string. | ||
else ms.FormatString = "#,##0.00"; | ||
} | ||
} | ||
``` | ||
### Explanation | ||
The script takes each of the selected measures and loops through them to set a default format string according to various conditions. |
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