Skip to content

Instantly share code, notes, and snippets.

View data-goblin's full-sized avatar

Kurt data-goblin

View GitHub Profile
#r "System.Net.Http"
#r "System.Windows.Forms"
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using System;
using System.IO;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
// Custom form for collecting inputs
class InputForm : Form
{
# Sample visual - requires input dataframe 'df'. Expected to run in a Fabric notebook.
import matplotlib.pyplot as plt
import seaborn as sns # Use sns instead of sb for consistency with common practice
import numpy as np
import pandas as pd
import warnings
# Suppress the specific FutureWarning about use_inf_as_na
warnings.filterwarnings("ignore", category=FutureWarning,
// Tabular Editor C# script for generating measure descriptions by using Claude 3.7 Sonnet
// Provided as-is; tested on TE3. The script itself was generated by using Claude 3.7 sonnet (i.e. not human-written).
// Requirements: Connected to a model, selecting a measure or column (or both) and added your Claude API key
// Note: Claude API keys require that you purchase credits; minimum of 5 USD
// Warning: Don't use on models with sensitive or confidential information. Validate all outputs before using them.
// Output: 1-3 bullet points descriptions for the fields you select and run the script on.
@data-goblin
data-goblin / format-m-expression.csx
Created March 9, 2023 20:01
A C# Script for tabular editor that formats the power query of a shared expression.
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
// URL of the powerqueryformatter.com API
string powerqueryformatterAPI = "https://m-formatter.azurewebsites.net/api/v2";
// HttpClient method to initiate the API call POST method for the URL
@data-goblin
data-goblin / 🐍Snek!.csx
Last active June 27, 2024 20:24
a Tabular Editor script to play a Snake game.
#r "System.Drawing"
// PLAY SNEK!
// By Kurt Buhler, Data Goblins; revisions by Daniel Otykier
// To use this script:
// 1. Open it in the Tabular Editor 3 Script Window.
// 2. Run it and have fun.
using System.Drawing;
using System.Drawing.Imaging;
@data-goblin
data-goblin / PreviewColumnsAndMeasures.csx
Last active June 14, 2024 11:45
A Tabular Editor C# script to test/check any valid combination of selected columns and/or measures in the model.
// Instructions
// ------------
// 1. Save this script as a macro with a context of 'Column' and 'Measure'
// 2. Configure a keyboard shortcut for the macro (i.e. ALT + C) if using Tabular Editor 3
// 3. Select any combination of columns & measures related in the model & run the script
// 4. The output will show you the evaluation result for all selected objects, presuming evaluation is valid
// Get column names
var _ColumnsList = new List<string>();
@data-goblin
data-goblin / CountModelObjects.csx
Created January 4, 2023 15:43
A Tabular Editor script to count model objects and output their results to a pop-up info box, to give a quick overview of the data model opened.
// Count calculation groups & calculation items
int _calcgroups = 0;
int _calcitems = 0;
foreach ( var _calcgroup in Model.CalculationGroups )
{
_calcgroups = _calcgroups + 1;
  foreach ( var _item in _calcgroup.CalculationItems )
  {
  _calcitems = _calcitems + 1;
   }
@data-goblin
data-goblin / FormatPowerQuery.csx
Last active December 4, 2024 21:15
A Tabular Editor C# script to format Power Query code for Partitions (M - Import) or Shared Expressions.
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
// URL of the powerqueryformatter.com API
string powerqueryformatterAPI = "https://m-formatter.azurewebsites.net/api/v2";
// HttpClient method to initiate the API call POST method for the URL
@data-goblin
data-goblin / selected-measure-dependancies_devops_mermaid.csx
Created June 29, 2022 15:07
A Tabular Editor C# script to generate a context-dependent mermaid diagram for Azure DevOps Wikis (flowchart) of measure dependencies based on the selected measure.
// This code is still WIP, it doesn't entirely filter the lineage. Feel free to make adjustments.
string dependancies = "::: mermaid\ngraph LR;\n%% Measure dependancy mermaid flowchart";
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
foreach(var _measures in Model.AllMeasures )
{
// Deep lineage for upstream measures