This file contains hidden or 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
let | |
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], | |
ToRows = Table.FromList( Table.ToRows( Source ), Splitter.SplitByNothing(), {"Trans"}), | |
BuySell = Table.AddColumn(ToRows, "BuySell", each [ | |
a = [Trans], | |
b = List.Transform(a, each List.PositionOf(a, _)), | |
c = List.Transform(a, each 1), | |
d = Table.FromColumns( {a, b, c}, {"Buy", "BuyPos", "B1"}), | |
e = Table.FromColumns( {a, b, c}, {"Sell", "SellPos", "S1"}), | |
f = Table.SelectRows( Table.Join( d, "B1", e, "S1" ), each [BuyPos] < [SellPos]), |
This file contains hidden or 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
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 ============================================================ |
This file contains hidden or 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
//C# script for Tabular Editor/TE3 to extract table, column, relationship, and measure info in json format from Power BI PBIX files | |
//Written by Brian Julius, 3 Oct 2024 | |
// Specify the output file path | |
string outputFile = @"C:\Temp\PowerBI_Model_Info.txt"; // Change this to your desired path | |
using (var writer = new System.IO.StreamWriter(outputFile)) | |
{ | |
// TMSCHEMA_TABLES | |
writer.WriteLine("TMSCHEMA_TABLES"); |
This file contains hidden or 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
// C# TE3 script to add measure name, measure description/purpose, and DAX code to the measure tooltip for each measure in a selected table | |
// developed by Brian Julius, Sep 27, 2024 | |
string apiKey = System.Environment.GetEnvironmentVariable("OPEN_AI_TE3_API_KEY"); | |
if (string.IsNullOrEmpty(apiKey)) | |
{ | |
Error("API key not found in environment variable 'OPEN_AI_TE3_API_KEY'."); | |
return; | |
} |
This file contains hidden or 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 GPT directly collects no data regarding your queries provided, and does not give Open AI permission to train its models | |
on the conversations with the GPT | |
It does use the Power Query formatter API, documented at https://www.durchblick-durch-daten.de/power-query/m-formatter/ | |
This formatter does not collect any metadata, with the exception of Error tracking. | |
It does track Errors that occur during formatting in order to fix bugs and improve their service. | |
In these cases metadata about the error is sent to the azure app insights remote service which contains a stacktrace. | |
This stacktrace might indirectly contain some information about the query that caused the error |
This file contains hidden or 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
"gpt-4-turbo" meta [IsParameterQuery=true, List={"gpt-4o-mini", "gpt-4o", "gpt-4", "gpt-4-turbo"}, DefaultValue="gpt-4o-mini", Type="Text", IsParameterQueryRequired=true] | |
//Created by Brian Julius | |
//Contact me at: https://www.linkedin.com/posts/brianjuliusdc | |
//This query needs to accompany the M Code Help function, to allow selection of the appropriate GPT-4 series model. |
This file contains hidden or 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
let | |
AnalyzeDataWithChatGPT = (HelpRequest as text ) as text => | |
let | |
apikey = Text.FromBinary(File.Contents("C:\temp\PQ_API_KEY.txt")), | |
GPTPrompt = Json.FromValue( | |
[ | |
model = ModelToUse, | |
messages = { | |
[ role = "system", content = "You are an expert in Power Query and M code. Provide a clear, detailed answer to the question below related to M code. Include specific examples to help explain concepts" ], | |
[ role = "user", content = HelpRequest ] |
This file contains hidden or 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
import zipfile | |
import os | |
def extract_bim_from_pbix(pbix_path, output_dir): | |
# Ensure the output directory exists | |
os.makedirs(output_dir, exist_ok=True) | |
# Extract the pbix file (which is a zip file) | |
with zipfile.ZipFile(pbix_path, 'r') as pbix_zip: | |
# Extract all files to the output directory |
This file contains hidden or 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
let | |
Source = Table.AddColumn( | |
Table.FromList({1, 2, 5, 10}, Splitter.SplitByNothing(), {"Denoms"}, null, null), | |
"Target", | |
each 11 | |
), | |
Rscript = R.Execute( | |
"df <- dataset#(lf)coin_combinations <- function(target, coins) {#(lf) dp <- vector(""list"", target + 1)#(lf) dp[[1]] <- list(numeric(0)) #(lf) for (coin in coins) {#(lf) for (amount in coin:target) {#(lf) if (!is.null(dp[[amount - coin + 1]])) {#(lf) for (combination in dp[[amount - coin + 1]]) {#(lf) dp[[amount + 1]] <- append(dp[[amount + 1]], list(c(combination, coin)))#(lf) }#(lf) }#(lf) }#(lf) }#(lf) #(lf) return(dp[[target + 1]])#(lf)}#(lf)#(lf)target_sum <- max(df$Target)#(lf)coin_denominations <- as.vector(df$Denoms)#(lf)combinations <- coin_combinations(target_sum, coin_denominations)#(lf)max_length <- max(sapply(combinations, length))#(lf)padded_combinations <- lapply(combinations, function(x) {#(lf) length(x) <- max_length#(lf) return(x)#(lf)})#(lf)#(lf)combs_df <- do.call( |
This file contains hidden or 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
let | |
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], | |
AddIndex = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type), | |
AddIndex2 = Table.AddIndexColumn(AddIndex, "Index.1", 0, 1, Int64.Type), | |
IntDiv = Table.TransformColumns(AddIndex2, {{"Index", each Number.IntegerDivide(_, 2), Int64.Type}}), | |
Modulo = Table.TransformColumns(IntDiv, {{"Index.1", each Number.Mod(_, 2), type number}}), | |
Piv = Table.Pivot(Table.TransformColumnTypes(Modulo, {{"Index.1", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(Modulo, {{"Index.1", type text}}, "en-US")[Index.1]), "Index.1", "Date & Orders"), | |
RemCol = Table.RemoveColumns(Piv,{"Index"}), | |
RenCol = Table.RenameColumns(RemCol,{{"0", "Date"}, {"1", "Order"}}), | |
ReType = Table.TransformColumnTypes(RenCol,{{"Date", type date}}), |