Skip to content

Instantly share code, notes, and snippets.

View cbaragao's full-sized avatar

Chris Aragao cbaragao

View GitHub Profile
EVALUATE
VAR __tables =
SELECTCOLUMNS(
INFO.VIEW.TABLES( ),
"ObjectId", [ID],
"ObjectType", "Table",
"Type", "N/A",
"Object", [Name],
"Desc", [Description],
"Hidden", FALSE( ),
(sharepoint_site as text) =>
let
Source = OData.Feed(sharepoint_site & "/_api/web/lists", null, [Implementation = "2.0"]),
Select_Columns = Table.SelectColumns(Source, {"Id", "Title", "ListItemEntityTypeFullName"}),
Set_Types = Table.TransformColumnTypes(
Select_Columns,
{{"Id", type text}, {"Title", type text}, {"ListItemEntityTypeFullName", type text}}
)
in
Set_Types
(sharepoint_site as text, folder_name as text) =>
let
Source =
Record.SelectFields(OData.Feed(
sharepoint_site & "/_api/web/GetFolderByServerRelativeUrl('" & folder_name & "')",
null,
[Implementation = "2.0"]
), "Files")[Files],
Select_Columns = Table.SelectColumns(
Source,
(sharepoint_site as text, list_title as text) =>
let
Source = Record.SelectFields(
OData.Feed(
sharepoint_site & "/_api/lists/getbytitle('" & list_title & "')",
null,
[Implementation = "2.0"]
),
"Fields"
)[Fields],
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Function AUTOCORR(dataRange As Range, lag As Integer) As Double
Dim n As Long
Dim i As Long
Dim mean As Double
Dim numerator As Double
Dim denominator As Double
Dim values() As Double
' Get number of points
n = dataRange.Count
-- Using DuckDb
-- Example is Lag 1
CREATE TEMP TABLE t1 (
SERIES DECIMAL(18,2)
);
INSERT INTO t1 VALUES(895);
INSERT INTO t1 VALUES(432);
INSERT INTO t1 VALUES(282);
INSERT INTO t1 VALUES(879);
function Get-RecentFiles {
param (
[string]$Path = ".",
[int]$Days = 1,
[switch]$Recurse,
[string]$Extension
)
if (-Not (Test-Path $Path)) {
Write-Error "Path not found: $Path"
Import-Module PSDuckDB
# Start timing
$startTime = Get-Date
# Parameters
$table = "test_table"
$sql = "SELECT * FROM $table"
$output = "Output\QueryResults.csv"
# Create a connection
// Moving Average
#r "Microsoft.VisualBasic"
using Microsoft.VisualBasic;
using System.Text.RegularExpressions;
// Select a measure
var offsetMeasure = Model.SelectMeasure();
// Select an offset column