Skip to content

Instantly share code, notes, and snippets.

@ImkeF
Last active April 19, 2022 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ImkeF/99c7e2dcca4b49076a5741dd5914bcce to your computer and use it in GitHub Desktop.
Save ImkeF/99c7e2dcca4b49076a5741dd5914bcce to your computer and use it in GitHub Desktop.
let func =
(SqlExpression as text) =>
let
Source = Expression.Evaluate(SqlExpression.ToExpression(SqlExpression, #shared), #shared) (#shared)
in
Source
, documentation = [
Documentation.Name = " Syntax.UseSQL
", Documentation.Description = " Use SQL-statement to query your M-tables (!!!) in your current file.
" , Documentation.LongDescription = " Use SQL-statement to query your M-tables (!!!) in your current file. This is an experimental feature that might be removed.
", Documentation.Category = " AccessingData
", Documentation.Source = " https://ssbi-blog.de/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-3/#comment-134
", Documentation.Author = " Imke Feldmann: www.TheBIccountant.com
", Documentation.Examples = {[Description = "
" , Code = "
", Result = "
"]}]
in
Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation))
@rudzimj
Copy link

rudzimj commented Apr 19, 2022

I can't get this to accept an SQLExpression that uses CASE WHEN. Is this possible? Is only T-SQL supported or can other SQL variants be used?

@ImkeF
Copy link
Author

ImkeF commented Apr 19, 2022

Sorry, but I'm not aware of these details.
As said in the function documentation, this is an experimental feature - I wouldn't be surprised to find some limitations in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment