c-sharp-scripting

Write and execute C# scripts against Power BI semantic models using Tabular Editor.

6|3|Updated Jul 4, 2026
One-click install
npx skills add https://github.com/InsightfulAnalytics/PBI_Agentic_Dev --skill c-sharp-scripting-insightfulanalytics
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: c-sharp-scripting
Source: https://github.com/InsightfulAnalytics/PBI_Agentic_Dev/tree/main/plugins/tabular-editor/skills/c-sharp-scripting
Command: npx skills add https://github.com/InsightfulAnalytics/PBI_Agentic_Dev --skill c-sharp-scripting-insightfulanalytics

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Automating repetitive Power BI semantic model changes—like bulk-updating measures, creating calculation groups, or configuring RLS—normally requires tedious manual clicks in the model designer. This Skill lets you write and run C# scripts and macros through Tabular Editor 2/3 to perform those operations programmatically. ## Core Features & Use Cases - TOM API Scripting: Create, modify, and delete measures, columns, tables, relationships, roles, hierarchies, partitions, and calculation groups via the Tabular Object Model. - CLI and IDE Execution: Run scripts against XMLA workspaces, local BIM/TMDL files, or live Power BI Desktop instances using the Tabular Editor CLI or interactive IDE. - 180 Ready-Made Examples: Adapt working .csx scripts across 20 categories (measures, format strings, SVG measures, partitions, roles) instead of writing from scratch. - Use Case: You need to apply a currency format string to every measure whose name ends in "Amount" across a large model—write one LINQ-filtered loop script and execute it in seconds. ## Quick Start Ask the agent to write a Tabular Editor C# script that hides all key columns and disables their summarization in your semantic model.

Frequently Asked Questions about c-sharp-scripting

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a C# script for Tabular Editor?▼

Write C# code using the Model and Selected objects to access tables, measures, and columns, ending every statement with a semicolon. Run it via the Tabular Editor CLI with the -S flag or directly in the IDE's Advanced Scripting window.

How to bulk update measures in Power BI with Tabular Editor?▼

Use LINQ to filter Model.AllMeasures and apply changes in a loop, such as setting FormatString or DisplayFolder on every matching measure. A single script with a ForEach loop updates hundreds of measures in one execution.

What is the difference between Tabular Editor 2 and 3 scripting?▼

Tabular Editor 2 uses the default compiler with older C# syntax, while Tabular Editor 3 uses Roslyn supporting up to C# 12. Use #if TE3 preprocessor directives to write version-specific code that runs in both.

Can Tabular Editor scripts connect to Power BI Desktop?▼

Yes, scripts can connect to a running Power BI Desktop instance using its localhost port, such as localhost:52123. They also support XMLA workspace connections, local BIM files, and TMDL definition folders.

Why does my Tabular Editor script stop without errors?▼

Silent failures usually occur when an object reference is null or an operation fails mid-script. Add Info() checkpoint statements after each step to identify exactly where execution stops, and verify objects exist with Contains() or FirstOrDefault().

How do I create a calculation group with a C# script?▼

Call Model.AddCalculationGroup with a name, set its Precedence, then add items with AddCalculationItem using DAX expressions built on SELECTEDMEASURE(). Set Ordinal on each item to control sort order in slicers.