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
@m-dekorte
m-dekorte / extendedDateTable.cs
Created March 11, 2025 11:34
Extended Date table C# script | Compatible with Tabular Editor versions TE2 and TE3
var dateTableName = "Dates"; // Name of your date table
var dateKeyColName = "Date"; // Name of the date key column in the table
var colOperations = new List<Tuple<string, string, bool>>(){
Tuple.Create("Quarter & Year", "QuarternYear", true),
Tuple.Create("Month & Year", "MonthnYear", true),
Tuple.Create("Month Name", "MonthOfYear", true),
Tuple.Create("Month Short", "MonthOfYear", true),
Tuple.Create("Month Initial", "MonthOfYear", true),
Tuple.Create("Week & Year", "WeeknYear", true),
Tuple.Create("Day of Week Name", "DayOfWeek", true),
@m-dekorte
m-dekorte / extendedDateTable.pq
Last active June 11, 2025 10:01
Extended Date table M function | Creates an ISO-8601 type calendar
let
fnDateTable = ( StartDate as date, EndDate as date, optional FYStartMonthNum as number, optional Holidays as list, optional WDStartNum as number, optional AddRelativeNetWorkdays as logical ) as table =>
let
FYStartMonth = List.Select({1..12}, each _ = FYStartMonthNum){0}? ?? 1,
WDStart = List.Select({0..1}, each _ = WDStartNum){0}? ?? 0,
CurrentDate = Date.From(DateTimeZone.FixedUtcNow()),
DayCount = Duration.Days(Duration.From(EndDate - StartDate)) + 1,
weekStart = Day.Monday,
HolidaysProvided = Holidays <> null,
@bjulius
bjulius / gist:ff2d3e50dd36b7bbe5cb5f757ee0d467
Created October 24, 2024 13:34
DAX SVG Measure to Generate IBCS-Style Bullet Charts
//Created by Brian Julius, 23 Oct 2024 using AI model o1-P
BulletChartSVG =
VAR __TotalSales = [Total Sales]
VAR __TargetSales = [Current Year Sales Target]
-- Normalize the bars by using the maximum target sales across all data
VAR __MaxTargetSales = [Max Sales Target]
-- Scale the bars based on the maximum target sales
@bjulius
bjulius / gist:3aa8a47813582fd62f5949ce5dff7a0f
Created October 8, 2024 06:05
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
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,
# 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.
target card =
// unsat, below, near, hit
VAR _Q1_result = "unsat"
VAR _Q2_result = "below"
VAR _Q3_result = "near"
VAR _Q4_result = "hit"
Sparkline =
// dummy value in a table
VAR _vals = {
( 0, 500 ),
( 1, 700 ),
( 2, 1200 ),
( 3, 1250 ),
( 4, 550 ),
( 5, 780 ),
( 6, 990 ),
@Giammaria
Giammaria / spec.json
Created November 15, 2023 17:45
20231115_faceted_bar_dynamic_labels_vl
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"transform": [
{"filter": "indexof(selectedDepartments, datum['Department']) >=0"},
{"fold": ["Budgeted $", "Paid $"]},
{
"joinaggregate": [
{"op": "min", "field": "value", "as": "min"},
{"op": "max", "field": "value", "as": "max"}
],
// white wine dataset used from http://archive.ics.uci.edu/dataset/186/wine+quality
{
"data": {
"name": "dataset"
},
"params": [
{
"name": "grid",
"select": "interval",