Skip to content

Instantly share code, notes, and snippets.

View Hugoberry's full-sized avatar

Igor Cotruta Hugoberry

View GitHub Profile
@Hugoberry
Hugoberry / ExampleOutput.csv
Created March 6, 2023 16:35
DAX measure that formats a measure `[Quantity]` into a roman numeral
Brand Quantity Roman Quantity
A. Datum 6897 V̅I̅DCCCXCVII
Adventure Works 10901 X̅CMI
Contoso 53151 L̅MMMCLI
Fabrikam 10973 X̅CMLXXIII
Litware 10130 X̅CXXX
Northwind Traders 2311 MMCCCXI
Proseware 9322 I̅X̅CCCXXII
Southridge Video 14866 X̅I̅V̅DCCCLXVI
Tailspin Toys 10590 X̅DXC
@Hugoberry
Hugoberry / BetterRevenue.dax
Last active March 3, 2023 18:00
A DAX measure definition that formats the Revenue numbers in a wordly way. It spells out numbers 1,812,343,434,567,812 like to `one quadrillion eight hundred and twelve trillion three hundred and forty-three billion four hundred and thirty-five million five hundred and sixty-eight thousand eight hundred and twelve`
Better Revenue_ =
VAR scale =
LEN ( [Revenue] )
RETURN
CONCATENATEX (
ADDCOLUMNS (
ADDCOLUMNS (
ADDCOLUMNS (
GENERATESERIES ( 0, scale / 3 ),
"Factors",
@Hugoberry
Hugoberry / powerbi-lineage.jq
Last active November 4, 2022 15:59
A jq parser for the internal PowerBI file *.pbix/Report/Layout. It surfaces the columns from the datamodel used in the visualizations.
[.sections[] | {
page: .displayName,
visuals: [ .visualContainers[].config |
fromjson |
.singleVisual |
select(has("projections"))|
{
type:.visualType,
projections: .projections |
{(keys[0]):[.[keys[0]][] |
@Hugoberry
Hugoberry / decompile.pq
Created June 22, 2022 10:00
Power Query attempt at decompiling a function call
t29
skippedInput = List.Skip(list,offset)
t28 = if (count = null)
then skippedInput
else List.FirstN(skippedInput,count)
@Hugoberry
Hugoberry / list-cheat-sheet-unicode.md
Last active April 16, 2022 21:38
PowerQuery List functions with unicode examples

List functions

Quick visual overview:

List.Zip({{"■","●"},{"▲","♦"}}) ⇒ {{"■","▲"},{"●","♦"}}
List.Reverse({"■","●","▲"}) ⇒ {"▲","●","■"}
List.Sort({"■","●","■"}) ⇒ {"■","■","●"}
List.Select({"■","●","■"}, each _="■")  ⇒ {"■","■"}
List.Transform({"■","●","▲"}, each "■") ⇒ {"■","■","■"}
List.PositionOf({"■","●","▲"},"▲") ⇒ 2
List.PositionOfAny({"■","●","▲"},{"♦","●"}) ⇒ 1
@Hugoberry
Hugoberry / list-cheat-sheet.md
Last active April 16, 2022 21:39
PowerQuery list functions cheat sheet

List functions

Addition

List.Sum({1, 2, 3}) ⇒ 6

Averages

List.Average({3, 4, 6}) ⇒ 4.333333333333333
List.Mode({"A", 1, 2, 3, 3, 4, 5}) ⇒ 3
List.Modes({"A", 1, 2, 3, 3, 4, 5, 5}) ⇒ {3,5}
@Hugoberry
Hugoberry / XML2DDL.XSLT
Created May 18, 2021 09:41
XSLT for transforming an XML doc into DDl statements for schema population
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsl:output method="text" omit-xml-declaration="yes" />
<xsl:template match="/">
<xsl:text>
-- ---------------------------------------------------------------
-- DDL generated from a .Net DataSet XSD via XSLT
@Hugoberry
Hugoberry / DAX.xmla
Created May 17, 2021 10:05
XMLA script to surface all DAX function definitions for SSAS
<Execute xmlns="urn:schemas-microsoft-com:xml-analysis">
<Command>
<Statement>
SELECT [Function_name], [ParameterInfo], [Description], [Interface_name], [Library_name] FROM $SYSTEM.MDSCHEMA_FUNCTIONS WHERE [Origin]=3 OR [Origin]=4
</Statement>
</Command>
<Properties>
<PropertyList>
<Catalog>a637e190-ed9c-46eb-84d7-3dc22e31a2e1</Catalog>
</PropertyList>
@Hugoberry
Hugoberry / SparksTheme.json
Created March 21, 2021 18:40
PowerBI theme which uses Sparks font for sparkline rendering in matrix/pivot tables
{
"name": "Sparkline Typeface",
"visualStyles": {
"pivotTable": {
"Default": {
"values": [
{
"fontFamily": "Sparks Bar"
}
]
@Hugoberry
Hugoberry / UnicodeMicrocharts.dax
Created March 18, 2021 23:19
Exploring displaying microcharts and sparklines in table/matrix visual in PowerBI
Spark = {
("Bar chart 100%","⬛⬛⬛⬛⬛⬛⬜⬜⬜⬜"),
("Bar chart 1","▧▧▧▧▧▧▧▧▧"),
("Bar chart 2","▧▧▧"),
("Bar chart 3","▧▧▧▧▧▧▧"),
("Stacked bar chart 1","▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░"),
("Bullet chart","█████████▒▒▒▒▒▒▒▒▒│▒▒"),
("Win loss 1","▖▗▘▘▗▘▘▞"),
("Win loss 2","▀▄▄▄▀▄▀▄▀▀▄▀▄▄▀▄▄▀▄▀"),
("Comparative Horizontal Circle 1","○○●●●●●●●|○○○○○○○○○○○"),