Skip to content

Instantly share code, notes, and snippets.

View PBI-DataVizzle's full-sized avatar
💭
Shizzle my Vizzle 🤓

Imran Haq PBI-DataVizzle

💭
Shizzle my Vizzle 🤓
View GitHub Profile
@PBI-DataVizzle
PBI-DataVizzle / gist:9391809476ef82ead8bf08d79928b898
Created October 8, 2024 16:07 — forked from bjulius/gist:3aa8a47813582fd62f5949ce5dff7a0f
Batch file to extract BIM files from every PBIX file in a directory
REM Uses pbi-tools to extract the data model info and create the BIM file associated with each PBIX file in the directory
REM Batch file code written by Brian Julius, October 8, 2024
REM @echo off
SETLOCAL ENABLEDELAYEDEXPANSION
REM ============================================================
REM Batch Script to Extract BIM Files from PBIX Files
REM All PBIX files are in C:\test
REM All BIM files will be written to C:\test\bim_files
REM ============================================================
let
Switch = Function.From(
type function (value as any, l as list, default as any) as any,
(params) =>
let
// Function to select nth item of list
// If you pass in zero, you get even indices
// If you pass in one, you get odd indices
fnSelectEvenOdd = (lst as list, remainder as number) as list =>
let
let
pqmath.Benford =
let
Benford = Function.From(
type function (num as number) as record,
(params) =>
let
len = Text.Length(Text.From(params{0})),
first = if len >= 1 then Number.From(Text.ToList(Text.From(params{0})){0}) else null,
second = if len >= 2 then Number.From(Text.ToList(Text.From(params{0})){1}) else null,
Sparkline Line =
// Static line color - use %23 instead of # for Firefox compatibility
VAR LineColor = "%2301B8AA"
// "Date" field used in this example along the X axis
VAR XMinDate = MIN('Table'[Date])
VAR XMaxDate = MAX('Table'[Date])
// Obtain overall min and overall max measure values when evaluated for each date
# Install the MicrosoftPowerBIMgmt module required for managing Power BI resources.
# This module is installed for the current user only, to avoid system-wide changes.
Install-Module -Name MicrosoftPowerBIMgmt -Scope CurrentUser
# Authenticate to the Power BI Service.
# This step is necessary to access and manage Power BI resources.
Login-PowerBIServiceAccount
# Function to retrieve all Power BI workspaces.
# It fetches data from the Power BI API and handles pagination to get all workspaces.
@PBI-DataVizzle
PBI-DataVizzle / AutoPopulateMeasureDescriptionsFromOpenAIWithDelay.csx
Created April 6, 2024 03:46 — forked from dgosbell/AutoPopulateMeasureDescriptionsFromOpenAIWithDelay.csx
Update Tabular Model Descriptions from ChatGPT with rate limiting logic
#r "System.Net.Http"
using System.Net.Http;
using System.Text;
using Newtonsoft.Json.Linq;
// You need to signin to https://platform.openai.com/ and create an API key for your profile then paste that key
// into the apiKey constant below
const string apiKey = "<YOUR API KEY HERE>";
const string uri = "https://api.openai.com/v1/completions";
const string question = "Explain the following calculation in a few sentences in simple business terms without using DAX function names:\n\n";
// =====================================
// Author: Darren Gosbell
// Date: 12 Apr 2023
// This script works in Tabular Editor and sets the MaxParallelismPerQuery
// setting at the database level.
// =====================================
if (Model.Database.CompatibilityLevel < 1569)
{
Model.Database.CompatibilityLevel = 1569;
// This gist containt useful pieces of DAX code
@PBI-DataVizzle
PBI-DataVizzle / 00 Tabular editor scripts
Created March 7, 2024 12:49 — forked from OscarValerock/00 Tabular editor scripts
Tabular editor scripts for Power BI
//This gist contains useful tabular editor scripts.
// This gist containt useful pieces of M Query code