Skip to content

Instantly share code, notes, and snippets.

CREATE TABLE [dwh].[TargetPerConsultant](
[RowID] [int] IDENTITY(1,1) PRIMARY KEY,
[Firstname] [varchar](50) NULL,
[TargetAmount] [smallmoney] NULL
) ON [PRIMARY]
GO
INSERT INTO [dwh].[TargetPerConsultant] (FirstName,TargetAmount)
VALUES ('Arthur',1200),
('Erik', 1000),
CREATE view [Model].[vw_GeoIntersects]
as
WITH Coordinates AS (
SELECT
ID
, Latitude
, Longitude
, geometry::Point(Longitude, Latitude, 0) AS LatLon
@Erik-H-zz
Erik-H-zz / ConvertPolygonToGeometry.sql
Created March 11, 2022 09:25
Converting Polygon text format to geometry format
SELECT geometry::STPolyFromText ('POLYGON((4.482593 51.904314, 4.484181 51.903189, 4.492163 51.906790, 4.489653 51.907769, 4.482593 51.904314))', 0)
@Erik-H-zz
Erik-H-zz / DaysSinceLastSale.dax
Created March 1, 2022 17:27
The amount of days between the previous sale and the current one.
Days since last sale =
DATEDIFF(
[Previous Date of Sales]
, MIN(FactInternetSales[OrderDate])
, DAY
)
@Erik-H-zz
Erik-H-zz / ValueofPreviousDateSales.Dax
Created March 1, 2022 17:25
Get the value of the previous sales date
Value of Previous Date Sales =
VAR PreviousDate = [Previous Date of Sales]
RETURN
CALCULATE(
[Sum Amount]
,'FactInternetSales'[OrderDate] = PreviousDate
)
@Erik-H-zz
Erik-H-zz / PreviousDateofSales.dax
Created March 1, 2022 17:15
Get the previous date of sales
Previous Date of Sales =
MAXX(
ADDCOLUMNS(
SUMMARIZE(
'FactInternetSales'
,'Product Name'[EnglishProductName]
,'FactInternetSales'[OrderDate]
)
,"@PreviousDate"
, CALCULATE(
@Erik-H-zz
Erik-H-zz / .json
Last active November 11, 2021 12:32
{"type":"FeatureCollection", "features": [
{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-0.08555539569718484,51.51981579755783],[-0.0834559420329396,51.51981579755783],[-0.08141032051393143,51.52091610672171],[-0.08141032051393143,51.522016415885574],[-0.07828805609018208,51.522016415885574],[-0.07931086684968619,51.518715488393966],[-0.07828805609018208,51.518715488393966],[-0.07721141318544089,51.516514870066224],[-0.07408914876169159,51.51431425173849],[-0.07306633800218748,51.51211363341075],[-0.07306633800218748,51.50991301508301],[-0.07516579166643272,51.50991301508301],[-0.07618860242593684,51.51101332424688],[-0.07931086684968619,51.50991301508301],[-0.07931086684968619,51.507712396755274],[-0.08141032051393143,51.50881270591914],[-0.0886776601209342,51.50881270591914],[-0.09179992454468355,51.50991301508301],[-0.09599883187317404,51.50991301508301],[-0.1001439070564275,51.51101332424688],[-0.11161015399192076,51.51101332424688],[-0.11161015399192076,51.51541456090236],[-0.113655775
#Log in to Power BI Service
Login-PowerBI -Environment Public
#First, Collect all (or one) of the workspaces in a parameter called PBIWorkspace
$PBIWorkspace = Get-PowerBIWorkspace # Collect all workspaces you have access to
#$PBIWorkspace = Get-PowerBIWorkspace -Name 'My Workspace Name' # Use the -Name parameter to limit to one workspace
#Now collect todays date
$TodaysDate = Get-Date -Format "yyyyMMdd"
{
"type": "AdaptiveCard",
"body": [
{
"type": "ColumnSet",
"separator": true,
"columns": [
{
"type": "Column",
"width": "stretch",
IsAboveThreshold = IF([Lastest CPU] > [Threshold (average past 5)] +5 , 1 , 0)