Skip to content

Instantly share code, notes, and snippets.

{
"data": {"name": "dataset"},
"vconcat": [
{
"mark": {
"type": "text",
"fontSize": 40,
"align": "left",
"baseline": "top",
@mlongoria
mlongoria / FlowerSVGPath.txt
Created March 29, 2023 03:22
Flower SVG for deneb
M0 -0.97Q 0.62 -0.76 0 0.08Q 0.62 -0.76 1 -0.24Q 0.67 0.3 0 0.08Q 0.67 0.3 0.62 0.93Q 0 0.79 0 0.08Q 0 0.79 -0.62 0.93Q -1 0.3 0 0.08Q -1 0.3 -1 -0.24Q -0.62 -0.76 0 0.08Q -0.62 -0.76 0 -0.97Q 0.62 -0.76 0 0.08z
//list available DMVs
Select * from $SYSTEM.DBSCHEMA_TABLES where table_type = 'Schema' order by table_name
//Useful DMVs for 2016 SSAS Tabular Models
Select * from $SYSTEM.TMSCHEMA_ATTRIBUTE_HIERARCHY_STORAGES //distinct data count for each column
Select * from $SYSTEM.TMSCHEMA_ATTRIBUTE_HIERARCHIES //ties hierarchy id to column
SELECT * from $SYSTEM.TMSCHEMA_COLUMN_STORAGES //has order by column, row count is inaccurate
Select * from $SYSTEM.TMSCHEMA_COLUMNS //column name, ID for table, data type, category, hidden, iskey, isunique, is nullable, summarize by, expression for calc columns, hierarchy id, refresh time, modify time. source provider type, display folder
SELECT * from $SYSTEM.TMSCHEMA_DATA_SOURCES //connection string, account, impersonation mode, name
Select * from $SYSTEM.TMSCHEMA_HIERARCHIES //hierarchy name, display folder
@mlongoria
mlongoria / Comet.json
Last active August 18, 2022 04:45
Comet Chart Deneb
{
"data": {"name": "dataset"},
"title": "Change In Percent of Americans Living Alone - 1980 vs 2018",
"height": 40,
"width": 350,
"mark": {"type": "trail"},
"encoding": {
"facet": {
"field": "Entity",
"title": null,
{
"data": {"name": "dataset"},
"mark": "area",
"encoding": {
"x": {
"timeUnit": "weekyear",
"field": "Date",
"title": null,
"axis": {"domain": false, "format": "%b %Y", "tickSize": 0}
},
@mlongoria
mlongoria / DAXLostCustomers.txt
Created August 8, 2016 00:30
Shows the calculation of lost customers based upon sales fact using DAX for SSAS Tabular
Lost Customers :=
IF (
NOT (
MIN ( 'Date'[Full Date] )
> CALCULATE ( MAX ( Sales[Invoice Date] ), ALL ( Sales ) )
),
COUNTROWS (
FILTER (
ADDCOLUMNS (
FILTER (
@mlongoria
mlongoria / CreateDateAzureSQLDW.sql
Last active September 23, 2020 03:54
Creates a calendar table in Azure SQL Data Warehouse
--Creates a table called RPT.Calendar. Change the table name on line 69. Change date range on line 2.
DECLARE @StartDate DATE = '20100101', @NumberOfYears INT = 30;
-- prevent set or regional settings from interfering with
-- interpretation of dates / literals
CREATE TABLE #dimdate
(
[date] DATE,
[day] tinyint,
@mlongoria
mlongoria / Color 1.M
Created August 16, 2020 00:27
Color Contrast Math
let
//Get values 0 - 255
Source = Values,
//Call that column R for Red
#"R Dec" = Table.RenameColumns(Source,{{"Column1", "R Dec"}}),
//Crossjoin to Values to get Green values 0 - 255
#"G Dec" = Table.AddColumn(#"R Dec", "Custom", each Values),
#"Expanded G Dec" = Table.ExpandTableColumn(#"G Dec", "Custom", {"Column1"}, {"G Dec"}),
//Crossjoin to Values to get Blue values 0 - 255
#"B Dec" = Table.AddColumn(#"Expanded G Dec", "B", each Values),
@mlongoria
mlongoria / SQLDWTableSwapWithClassifications
Created May 29, 2019 22:50
Stored procedure to swap tables via RENAME and DROP TABLE and transfer any sensitivity classifications from the original table to the new table
CREATE PROC SwapWithMetadata
@SrcSchema NVARCHAR(128),
@SrcTable NVARCHAR(128),
@DestSchema NVARCHAR(128),
@DestTable NVARCHAR(128),
@TransferMetadata BIT,
@DropOldTable BIT
AS
BEGIN
<!-- This goes in your data flow as the source -->
<CustomComponent Name="TF Dynamics 365 <#=table.Name#>" ComponentTypeName="PragmaticWorks.TaskFactory.DynamicsSource" Version="1" ContactInfo="Dynamics Source;Pragmatic Works, Inc; Task Factory (c) 2009 - 2016 Pragmatic Works, Inc; http://www.pragmaticworks.com;support@pragmaticworks.com" UsesDispositions="true">
<Annotations>
<Annotation AnnotationType="Description">Extract data from Microsoft Dynamics CRM.</Annotation>
</Annotations>
<DataflowOverrides>
<OutputPath OutputPathName="Dynamics Source Output">
<!-- Iterate through the columns (I'm passing in table and column from another file), ignoring any audit columns you may have added to your table. Set the Error Row Disposition and Truncation Row Disposition. -->
<# foreach (var column in table.Columns.Where(c => !c.Name.Equals("AuditETLLogID") && !c.Name.Equals("AuditIn