This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code is still WIP, it doesn't entirely filter the lineage. Feel free to make adjustments. | |
string dependancies = "flowchart LR\n%% Measure dependancy mermaid flowchart"; | |
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
foreach(var _measures in Model.AllMeasures ) | |
{ | |
// Deep lineage for upstream measures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string dependancies = "flowchart LR\n%% Measure dependancy mermaid flowchart"; | |
foreach(var _measures in Model.AllMeasures ) | |
{ | |
var _upstream = _measures.DependsOn; | |
var _upstream_measures = _upstream.Measures.OfType<Measure>().Select(c => c).Distinct(); | |
dependancies += string.Format("\r\n\n%% [{1}] Dependancies:\n\t{0}[\"{1}\"]", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from azure.identity import InteractiveBrowserCredential | |
import requests, json | |
# Authenticate through the browser - not automated but alternatives exist | |
# Docs: https://docs.microsoft.com/en-us/python/api/azure-identity/azure.identity?view=azure-python | |
creds = InteractiveBrowserCredential() | |
scope = 'https://analysis.windows.net/powerbi/api/.default' | |
user_token = creds.get_token(scope) | |
user_token = user_token.token | |
user_header = {'Authorization': f'Bearer {user_token}'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################################################### | |
# Authentication - Replace string variables with your relevant values | |
######################################################################################### | |
import json, requests, pandas as pd | |
try: | |
from azure.identity import ClientSecretCredential | |
except Exception: | |
!pip install azure.identity | |
from azure.identity import ClientSecretCredential |
NewerOlder