Kommentare zu: The Environment concept in M for Power Query and Power BI Desktop, Part 2 https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-2/ Wir lieben Microsoft Power BI Fri, 22 Mar 2024 16:26:57 +0000 hourly 1 https://wordpress.org/?v=6.8.2 Von: Lars Schreiber https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-2/#comment-123 Fri, 20 Oct 2017 13:18:01 +0000 http://ssbi-blog.de/?p=1868#comment-123 Als Antwort auf Igor Cotruta.

Hey Igor,

like that a lot 🙂 So you have to define „meta“ in the same environment as your desired „x“ to pull it in. Great idea and pretty much around the corner 🙂

Cheers,
Lars

]]>
Von: Igor Cotruta https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-2/#comment-122 Thu, 19 Oct 2017 22:02:40 +0000 http://ssbi-blog.de/?p=1868#comment-122 Als Antwort auf Lars Schreiber.

Hi Konrad,
I don’t know if Power Query supports deep references, similar to other functional languages (like r with <<- assignment operator). But I do have a workaround for this.
Use the metadata tags
[a = [x=1, y=Value.Metadata(@a)[x], z=1+y] meta [x=x], b = 3, x = 4]
How meta is that 🙂 ?
I have a couple more examples If you're interested:
https://gist.github.com/Hugoberry/67c6b786a95d23f664918ace51011f67
Cheers,
Igor

]]>
Von: Lars Schreiber https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-2/#comment-121 Thu, 19 Oct 2017 14:24:54 +0000 http://ssbi-blog.de/?p=1868#comment-121 Als Antwort auf Konrad.

Hi Konrad,

I wasn’t able to access the outer x from inside the record a. I am not sure this is possible at all. But you can do the following: Wrap the record in a let expression and assign it to a variable („P“ in my example):

let
P = [a = [x=1, y=P[x], z=1+y], b = 3, x = 4]
in
P[a][y]

I want P[a][y] to be 4 (from the outer x) instead of 1 (from the inner x). Unfortunately this expression throws an error, because P is not part of it’s own environment. BUT you can add a @ to P:

let
P = [a = [x=1, y=@P[x], z=1+y], b = 3, x = 4]
in
P

The @ allows recursion, which in this example means to be able to call the record from inside the record itself. I learnd this from Igor Cotruta. If you want to dive deeper into it, take a look at chapter 6.3 in the Power Query language specification.

Thanks to Igor for adding recursion to this topic and thanks to you, Konrad, for beeing interested in this blog post 🙂

Cheers,
Lars

]]>
Von: Konrad https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-2/#comment-119 Thu, 19 Oct 2017 07:49:14 +0000 http://ssbi-blog.de/?p=1868#comment-119 Very interesting, I was wondering though, if it is at all possible to reference the „outer x“ within „a“ or is the inner x basically replacing the outer x when there is a name conflict?

]]>
Von: Lars Schreiber https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-2/#comment-118 Wed, 18 Oct 2017 20:05:40 +0000 http://ssbi-blog.de/?p=1868#comment-118 Als Antwort auf Igor.

Thanks Igor. That also applies to your posts. There will come more soon.

Cheers,
Lars

]]>
Von: Igor https://ssbi-blog.de/blog/technical-topics-english/the-environment-concept-in-m-for-power-query-and-power-bi-desktop-part-2/#comment-117 Wed, 18 Oct 2017 19:59:50 +0000 http://ssbi-blog.de/?p=1868#comment-117 Always a pleasure to read these articles. Keep them coming

]]>