<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Convert Dax Formula to Power Query in Desktop</title>
    <link>https://community.fabric.microsoft.com/t5/Desktop/Convert-Dax-Formula-to-Power-Query/m-p/3831465#M1237372</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="286703" data-lia-user-login="dirkkoch" class="lia-mention lia-mention-user"&gt;dirkkoch&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can achieve similar functionality in Power Query by creating a custom column. However, please note that Power Query doesn't support variables like DAX, so you'll need to work with nested functions instead. Here's the equivalent Power Query code:&lt;/P&gt;&lt;P&gt;```m&lt;BR /&gt;let&lt;BR /&gt;AktuellesDatum = [Datum],&lt;BR /&gt;LetzterUnfallTag = List.Max(&lt;BR /&gt;Table.SelectRows(#"PEL Unfallkreuz", each [PELA.Unfallfreie Tage] = 0 and [Datum] &amp;lt;= AktuellesDatum)[Datum]),&lt;BR /&gt;ErsterUnfallfreierTag = List.Min(Table.SelectRows(#"PEL Unfallkreuz", each [PELA.Unfallfreie Tage] &amp;gt; 0)[Datum]),&lt;BR /&gt;DaysDifference =&lt;BR /&gt;if LetzterUnfallTag = null then&lt;BR /&gt;Duration.Days(ErsterUnfallfreierTag - AktuellesDatum)&lt;BR /&gt;else&lt;BR /&gt;Duration.Days(LetzterUnfallTag - AktuellesDatum)&lt;BR /&gt;in&lt;BR /&gt;DaysDifference&lt;BR /&gt;```&lt;/P&gt;&lt;P&gt;This Power Query code calculates the number of days between the current date (`AktuellesDatum`) and either the last accident date (`LetzterUnfallTag`) or the first accident-free date (`ErsterUnfallfreierTag`). The result is then returned as the custom column value `DaysDifference`.&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Apr 2024 16:49:28 GMT</pubDate>
    <dc:creator>johnbasha33</dc:creator>
    <dc:date>2024-04-11T16:49:28Z</dc:date>
    <item>
      <title>Convert Dax Formula to Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/Convert-Dax-Formula-to-Power-Query/m-p/3830586#M1237198</link>
      <description>&lt;P&gt;I have the following DAX formula which is working fine in my PBI-report but now I want to create a custom column within a dataflow and I have to use Power Query language. Can someone convert this DAX-formula to Power Query language so that it will work identical?!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Unfallfrei_Zähler =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;AktuellesDatum&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;'PEL Unfallkreuz'&lt;/SPAN&gt;&lt;SPAN&gt;[Datum]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;LetzterUnfallTag&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'PEL Unfallkreuz'&lt;/SPAN&gt;&lt;SPAN&gt;[Datum]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp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N&gt;&lt;SPAN&gt;DATEDIFF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ErsterUnfallfreierTag&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;AktuellesDatum&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;DAY&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;DATEDIFF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;LetzterUnfallTag&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;AktuellesDatum&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;DAY&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 11:01:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/Convert-Dax-Formula-to-Power-Query/m-p/3830586#M1237198</guid>
      <dc:creator>dirkkoch</dc:creator>
      <dc:date>2024-04-11T11:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Dax Formula to Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/Convert-Dax-Formula-to-Power-Query/m-p/3831465#M1237372</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="286703" data-lia-user-login="dirkkoch" class="lia-mention lia-mention-user"&gt;dirkkoch&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can achieve similar functionality in Power Query by creating a custom column. However, please note that Power Query doesn't support variables like DAX, so you'll need to work with nested functions instead. Here's the equivalent Power Query code:&lt;/P&gt;&lt;P&gt;```m&lt;BR /&gt;let&lt;BR /&gt;AktuellesDatum = [Datum],&lt;BR /&gt;LetzterUnfallTag = List.Max(&lt;BR /&gt;Table.SelectRows(#"PEL Unfallkreuz", each [PELA.Unfallfreie Tage] = 0 and [Datum] &amp;lt;= AktuellesDatum)[Datum]),&lt;BR /&gt;ErsterUnfallfreierTag = List.Min(Table.SelectRows(#"PEL Unfallkreuz", each [PELA.Unfallfreie Tage] &amp;gt; 0)[Datum]),&lt;BR /&gt;DaysDifference =&lt;BR /&gt;if LetzterUnfallTag = null then&lt;BR /&gt;Duration.Days(ErsterUnfallfreierTag - AktuellesDatum)&lt;BR /&gt;else&lt;BR /&gt;Duration.Days(LetzterUnfallTag - AktuellesDatum)&lt;BR /&gt;in&lt;BR /&gt;DaysDifference&lt;BR /&gt;```&lt;/P&gt;&lt;P&gt;This Power Query code calculates the number of days between the current date (`AktuellesDatum`) and either the last accident date (`LetzterUnfallTag`) or the first accident-free date (`ErsterUnfallfreierTag`). The result is then returned as the custom column value `DaysDifference`.&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 16:49:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/Convert-Dax-Formula-to-Power-Query/m-p/3831465#M1237372</guid>
      <dc:creator>johnbasha33</dc:creator>
      <dc:date>2024-04-11T16:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Dax Formula to Power Query</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/Convert-Dax-Formula-to-Power-Query/m-p/3832740#M1237658</link>
      <description>&lt;P&gt;Thank you for the reply. Unfortunately I receive an error message saying&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;Expression.Error: During the evaluation a circular reference was detected.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;Details&lt;/SPAN&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;Reason = Expression.Error&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 06:29:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/Convert-Dax-Formula-to-Power-Query/m-p/3832740#M1237658</guid>
      <dc:creator>dirkkoch</dc:creator>
      <dc:date>2024-04-12T06:29:22Z</dc:date>
    </item>
  </channel>
</rss>

