-
-
Save PBI-DataVizzle/19e8ca3882a09a6a7102dbe87ee2b999 to your computer and use it in GitHub Desktop.
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 | |
fnGetSQLServer = | |
let | |
GetSQLServerType = type function ( | |
server as ( | |
type text | |
meta [ | |
Documentation.FieldCaption = "Server Name", | |
Documentation.FieldDescription = "SQL Server name", | |
Document.SampleValues = {"SERVER"}, | |
Formatting.IsMultiLine = false, | |
Formatting.IsCode = true | |
] | |
), | |
database as ( | |
type text | |
meta [ | |
Documentation.FieldCaption = "Database Name", | |
Documentation.FieldDescription = "Database name", | |
Document.SampleValues = {"Database"}, | |
Formatting.IsMultiLine = false, | |
Formatting.IsCode = true | |
] | |
), | |
sql as ( | |
type text | |
meta [ | |
Documentation.FieldCaption = "SQL", | |
Documentation.FieldDescription = "SQL Query Text", | |
Document.SampleValues = {"SELECT * FROM your_table"}, | |
Formatting.IsMultiLine = true, | |
Formatting.IsCode = true | |
] | |
) | |
) as table, | |
GetData = (server as text, database as text, sql as text) as table => | |
Value.NativeQuery( | |
Sql.Databases(server){[Name=database]}[Data], | |
sql, | |
null, | |
[EnableFolding = true, PreserveTypes = true] | |
) | |
in | |
Value.ReplaceType(GetData, GetSQLServerType) | |
in | |
fnGetSQLServer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment