Kommentare zu: The Environment concept in M for Power Query and Power BI Desktop, Part 3 https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-3/ Wir lieben Microsoft Power BI Fri, 22 Mar 2024 16:27:09 +0000 hourly 1 https://wordpress.org/?v=6.7.2 Von: editableforms https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-3/#comment-3786 Tue, 23 Aug 2022 09:48:57 +0000 http://ssbi-blog.de/?p=1908#comment-3786 Pretty good post. I have really enjoyed reading your blog posts. Anyway, I’ll be subscribing to your feed and I hope you post again soon.
biggest accounting forms

]]>
Von: Jon https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-3/#comment-2914 Tue, 14 Dec 2021 16:01:33 +0000 http://ssbi-blog.de/?p=1908#comment-2914 Hi Lars
Your post is excellent covering so many aspects of the M environments
Would like to ask you if you have an idea how to setup local (or external environments) that will contain the non-native (custom) M function. For example if the user have a repository of functions in github will be great to be able to turn it as part of the M environment. Hope my question make some sense
Cheers
Jon

]]>
Von: M Mysteries: SQL -> M (SqlExpression.ToExpression) | Ben Gribaudo https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-3/#comment-2380 Tue, 13 Jul 2021 20:46:25 +0000 http://ssbi-blog.de/?p=1908#comment-2380 […] goes to a comments exchange on Lars Schreiber’s The Self-Service BI Blog for the basic details of […]

]]>
Von: Curt Hagenlocher https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-3/#comment-137 Tue, 21 Nov 2017 17:04:10 +0000 http://ssbi-blog.de/?p=1908#comment-137 Als Antwort auf Imke Feldmann.

There are effectively two different environments here. Expression.Evaluate needs one that has the functions from the standard library, while the environment consumed both by SqlExpression.ToExpression and by the function it produces needs to have just the tables referenced by the T/SQL-compatible query text. Naturally, a single combined environment (like the one produced by #shared) can fill both roles.

]]>
Von: Imke Feldmann https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-3/#comment-136 Tue, 21 Nov 2017 16:26:23 +0000 http://ssbi-blog.de/?p=1908#comment-136 Als Antwort auf Imke Feldmann.

Sorry, my bad (had another Table1 in my queries) – so no question here.
But I will leave the „functionized“ version of the SqlExpression.ToExpression here without a constructed table in the environment. So this will work for all tables that exist in your current environment already:

(SqlExpression as text) =>
let
Source = Expression.Evaluate(SqlExpression.ToExpression(SqlExpression, #shared), #shared) (#shared)
in
Source

]]>
Von: Imke Feldmann https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-3/#comment-135 Tue, 21 Nov 2017 16:14:41 +0000 http://ssbi-blog.de/?p=1908#comment-135 Als Antwort auf Curt Hagenlocher.

Thanks Curt – that is pretty awesome 🙂
One question though:
If I convert this to a function that just takes the SQL-code as a parameter, I need to add #shared to the innermost environment, whereas that statement evaluates without any problems as a standalone expression. It seems that this will make Table1 part of the outer #shared-environments as well, which is fine – just that I don’t understand why this syntax actually works. So any explanation would be very welcomed!

(SqlExpression as text) =>
let
Source = Expression.Evaluate( SqlExpression.ToExpression( SqlExpression, [Table1=#table(type table [Column1 as text, Column2 as number], {{„X“, 1}, {„Y“, 2}})] & #shared) , #shared) (shared)
in
Source

]]>
Von: Curt Hagenlocher https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-3/#comment-134 Tue, 21 Nov 2017 14:53:51 +0000 http://ssbi-blog.de/?p=1908#comment-134 Even though this is technically an implementation detail which I think we reserve the right to change in the future, I’ll just leave this here:

SqlExpression.ToExpression(„select Column1 from Table1 where Column2 = 1“, [Table1=#table(type table [Column1 as text, Column2 as number], {{„X“, 1}, {„Y“, 2}})])

]]>
Von: Curt Hagenlocher https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-3/#comment-133 Tue, 21 Nov 2017 14:49:50 +0000 http://ssbi-blog.de/?p=1908#comment-133 Als Antwort auf Lars Schreiber.

The concatenation operator („&“) works on text, lists, records and tables.

]]>
Von: Lars Schreiber https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-3/#comment-132 Mon, 20 Nov 2017 07:34:20 +0000 http://ssbi-blog.de/?p=1908#comment-132 Als Antwort auf meng zong.

Hello Meng Zong,

I must confess that your first example cannot work in Excel from my point of view. If both variables are steps in the same query, then #shared cannot be the solution because #shared delivers the Global Environment and no variable from inside the same query. So in the described case you always have to go for the solution Expression.Evaluate („A“,[A=A]). BUT: I would rather solve the problem described by you with a parameterized function., reading the user’s table selection from the UI (propably Excel) and use this as input parameter for the table selection in Excel or Power BI Desktop.

Cheers,
Lars

]]>
Von: Lars Schreiber https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-3/#comment-131 Mon, 20 Nov 2017 06:52:09 +0000 http://ssbi-blog.de/?p=1908#comment-131 Als Antwort auf Maxim Zelensky.

Hey Maxim,

thanks for your positiv feedback. I wasn’t aware, that „&“ combines two records. Thanks for that hint 🙂

Cheers,
Lars

]]>