Skip to content

Instantly share code, notes, and snippets.

View deldersveld's full-sized avatar

David Eldersveld deldersveld

View GitHub Profile
Login-AzureRmAccount
$containerName = <<string containing container name>>
$storageContext = New-AzureStorageContext -ConnectionString <<connection string to storage account>>
$localDestinationPath = <<string containing file system path.>>
$blobPrefix = <<string containing prefix to search. wildcard character not needed after prefix.>>
#List
#Get-AzureStorageBlob -Context $storageContext -Container $containerName -Prefix $blobPrefix
$getFirstLine = $true
get-childItem "[path]\*.tsv" | foreach {
$filePath = $_
$lines = $lines = Get-Content $filePath
$linesToWrite = switch($getFirstLine) {
$true {$lines}
$false {$lines | Select -Skip 1}
@deldersveld
deldersveld / HexColorToRGB.dax
Last active July 13, 2018 03:30
DAX - Hex Color to RGB
Hex Color to RGB =
VAR HexColorValue = "#01B8AA"
// Do not change anything below this line
VAR PositionRed1 = RIGHT(LEFT(HexColorValue,2),1)
VAR PositionRed0 = RIGHT(LEFT(HexColorValue,3),1)
VAR PositionGreen1 = RIGHT(LEFT(HexColorValue,4),1)
VAR PositionGreen0 = RIGHT(LEFT(HexColorValue,5),1)
VAR PositionBlue1 = RIGHT(LEFT(HexColorValue,6),1)
VAR PositionBlue0 = RIGHT(LEFT(HexColorValue,7),1)
VAR Red1 = SWITCH(PositionRed1,"A",10,"B",11,"C",12,"D",13,"E",14,"F",15,PositionRed1) * 16
@deldersveld
deldersveld / RGBDecimalColorToHex.dax
Created July 13, 2018 11:59
DAX - RGB Decimal Color to Hex
RGB Decimal Color to Hex =
// Manually enter components of RGB decimal color value, e.g. "RGB(1,184,170)"
VAR RedDecimalColorValue = 1
VAR GreenDecimalColorValue = 184
VAR BlueDecimalColorValue = 170
//Decimal to Hex
VAR RedPosition0Dec = MOD(RedDecimalColorValue,16)
VAR RedPosition0Div = INT(RedDecimalColorValue / 16)
VAR RedPosition1Dec = MOD(RedPosition0Div,16)
VAR RedPosition1Div = INT(RedPosition0Div / 16)
Sparkline Line =
// Static line color - use %23 instead of # for Firefox compatibility
VAR LineColor = "%2301B8AA"
// "Date" field used in this example along the X axis
VAR XMinDate = MIN('Table'[Date])
VAR XMaxDate = MAX('Table'[Date])
// Obtain overall min and overall max measure values when evaluated for each date
Sparkline Column Categorical Axis =
// Static column color - use %23 instead of # for Firefox compatibility
VAR BarColor = "%2301B8AA"
VAR BarOutlineColor = "%23DDDDDD"
VAR BarOutlineWidth = 2
// Obtain number of columns - width generated based on column count (~20 column maximum for bar chart)
VAR BarCount = DISTINCTCOUNT('Table'[Customer Segment])
VAR BarWidth = INT(DIVIDE(100,BarCount))
// Obtain overall min and overall max measure values when evaluated for each column
VAR YMinValue = MINX(VALUES('Table'[Customer Segment]),CALCULATE([Measure Value]))
{
"version": "1.0",
"name": "[Tool Name]",
"description": "[Tool Description]",
"path": "C:\\[PATH TO PYTHON EXECUTABLE]\\python.exe",
"arguments": "C:/[PATH TO PYTHON SCRIPT].py \"%server%\" \"%database%\"",
"iconData": "data:image/png;base64,[YOUR BASE64 IMAGE CONTENT]"
}
import sys
print('Power BI Desktop Connection')
print(str(sys.argv[1]))
print(str(sys.argv[2]))
print('')
conn = "Provider=MSOLAP;Data Source=" + str(sys.argv[1]) + ";Initial Catalog='';"
print(conn)