View azsql_running_queries.sql
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
SELECT r.session_id | |
,s.login_name | |
,c.client_net_address | |
,s.host_name | |
,s.program_name | |
,st.TEXT | |
,s.STATUS | |
FROM sys.dm_exec_requests r | |
INNER JOIN sys.dm_exec_sessions s ON r.session_id = s.session_id | |
LEFT JOIN sys.dm_exec_connections c ON r.session_id = c.session_id |
View TMSCHEMA_COLUMNS-ExplicitDataType.txt
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
1 - (Calculated Column, so look at InferredDataType column) | |
2 - Text | |
6 - Whole Number | |
8 - Decimal Number | |
9 - Date | |
11 - Boolean | |
//https://docs.microsoft.com/en-us/analysis-services/tabular-models/data-types-supported-ssas-tabular?view=asallproducts-allversions | |
View azsql_table_size.sql
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
--Table size and properties | |
SELECT schema_name(t.schema_id) + '.' + t.name AS [table] | |
,p.[rows] | |
,cast(sum(spc.used_pages * 8) / 1024.00 AS NUMERIC(36, 2)) AS used_mb | |
,cast(sum(spc.total_pages * 8) / 1024.00 AS NUMERIC(36, 2)) AS allocated_mb | |
,p.index_id | |
,p.data_compression_desc AS [Index Data Compression] | |
,t.create_date | |
,t.lock_on_bulk_load | |
,t.lock_escalation_desc |
View data_last_refreshed.pq
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
let | |
Source = #table(type table[Date Last Refreshed=datetime], {{DateTimeZone.SwitchZone(DateTimeZone.UtcNow(),-8)}}), //PST is UTC-8 | |
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date Last Refreshed", type datetimezone}}) | |
in | |
#"Changed Type" |
View Get-AADUserInfo.ps1
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
<# | |
.DESCRIPTION | |
This script imports a list of UPN's and extracts more user information from Azure Active Directory via the AzureAD PS module. | |
.LINK | |
https://docs.microsoft.com/en-us/powershell/module/azuread/get-azureaduser?view=azureadps-2.0 | |
#> | |
$upns = import-csv "C:\Directory\File.csv" # Replace filepath here |
View quick_prior_month_sales.dax
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
Prior Month Sales = CALCULATE ( SUM( Sales[Revenue] ), PREVIOUSMONTH( Sales[Date].[Date] ) ) | |
// Quick measure uses DATEADD function instead | |
Prior Month Sales = CALCULATE ( SUM( Sales[Revenue] ), DATEADD( Sales[Date].[Date], -1, MONTH ) ) |
View Prior_Month_Sales.dax
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
Revenue PM = | |
var prior_month_start_date = EOMONTH( MIN ( Sales[Date] ), -2 ) + 1 | |
var prior_month_end_date = EOMONTH( MIN ( Sales[Date] ), -1 ) + 1 | |
RETURN | |
CALCULATE( | |
SUM ( Sales[Revenue] ), | |
FILTER ( | |
ALLSELECTED ( Sales ), | |
Sales[Date] >= prior_month_start_date && Sales[Date] < prior_month_end_date | |
) |
View DIAD_DAX_Samples.txt
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
//Date Table | |
Date = CALENDAR (DATE(2012,1,1), DATE(2018,12,31)) | |
Date = CALENDAR ("1/1/2012", 12/31/2018") | |
//Time Intelligence function | |
PY Sales = CALCULATE ( SUM ( Sales[Revenue] ), SAMEPERIODLASTYEAR( 'Date'[Date] ) ) | |
PM Sales = CALCULATE ( SUM ( Sales[Revenue] ), PREVIOUSMONTH( 'Date'[Date] ) ) | |
//Ratios | |
% Growth = DIVIDE(SUM(Sales[Revenue])-[PY Sales],[PY Sales]) |
View Calendar.pq
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
let | |
Source = fn_Calendar(#date(2018, 8, 1), Date.From(DateTime.FixedLocalNow()), null) | |
in | |
Source |
View fn_Calendar.pq
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
let CreateDateTable = (StartDate as date, EndDate as date, optional Culture as nullable text) as table => | |
let | |
// Determine number of days between start and end date | |
DayCount = Duration.Days(Duration.From(EndDate - StartDate)), | |
// Add a day back, as Duration math above will give you the days literally between rather than inclusive. Ex Dec 31 - Dec 1 = 30 days, but we need 31 days in that period | |
DayCountAdd = DayCount + 1, | |
// Create a Dates list object starting at the start date, for the duration of the day count, increment of one year | |
Source = List.Dates(StartDate,DayCountAdd,#duration(1,0,0,0)), | |
// Turn that date list into a table | |
TableFromList = Table.FromList(Source, Splitter.SplitByNothing()), |
NewerOlder