<?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 New calculated column too complex for me . in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2699248#M81592</link>
    <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;I hope that you can help me on this issue because I'm little disapointed about it .&lt;/P&gt;&lt;P&gt;My level in Dax is not sufficient to archive this .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table 'NewPBI" I would like create a calculated column "NewAmount"&amp;nbsp; with this king of approach&amp;nbsp;&lt;/P&gt;&lt;P&gt;let me explain with some examples&amp;nbsp;&lt;/P&gt;&lt;P&gt;Situation 1 : Scenario A = Scenario B&amp;nbsp; and only one&amp;nbsp; row for the combinaison Scenario A and G/L# so newAmount should be Amount&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;situation 2&amp;nbsp; : Scenario A &amp;lt;&amp;gt; Scenario B&amp;nbsp; and only one&amp;nbsp; row for the combinaison Scenario A and G/L# so newAmount should be the amount of the combination Scenario A and G/L#&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Situation 3&amp;nbsp; : multiple result for the combination of Scenario A and G/L #&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Scenario A = Scenario B then NewAmount = Amount&lt;/P&gt;&lt;P&gt;Scenario A &amp;lt;&amp;gt; Scenario B the NewAmount = 0&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the dax formula seems very complex so i hope that you can help me on this .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paololito&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 14 Aug 2022 16:38:58 GMT</pubDate>
    <dc:creator>paololito</dc:creator>
    <dc:date>2022-08-14T16:38:58Z</dc:date>
    <item>
      <title>New calculated column too complex for me .</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2699248#M81592</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;I hope that you can help me on this issue because I'm little disapointed about it .&lt;/P&gt;&lt;P&gt;My level in Dax is not sufficient to archive this .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table 'NewPBI" I would like create a calculated column "NewAmount"&amp;nbsp; with this king of approach&amp;nbsp;&lt;/P&gt;&lt;P&gt;let me explain with some examples&amp;nbsp;&lt;/P&gt;&lt;P&gt;Situation 1 : Scenario A = Scenario B&amp;nbsp; and only one&amp;nbsp; row for the combinaison Scenario A and G/L# so newAmount should be Amount&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;situation 2&amp;nbsp; : Scenario A &amp;lt;&amp;gt; Scenario B&amp;nbsp; and only one&amp;nbsp; row for the combinaison Scenario A and G/L# so newAmount should be the amount of the combination Scenario A and G/L#&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Situation 3&amp;nbsp; : multiple result for the combination of Scenario A and G/L #&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Scenario A = Scenario B then NewAmount = Amount&lt;/P&gt;&lt;P&gt;Scenario A &amp;lt;&amp;gt; Scenario B the NewAmount = 0&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the dax formula seems very complex so i hope that you can help me on this .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Paololito&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Aug 2022 16:38:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2699248#M81592</guid>
      <dc:creator>paololito</dc:creator>
      <dc:date>2022-08-14T16:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: New calculated column too complex for me .</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2699281#M81600</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="368503" data-lia-user-login="paololito" class="lia-mention lia-mention-user"&gt;paololito&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;My understanding of your problem:&lt;BR /&gt;scenario A &amp;amp; G/L :&amp;nbsp;unique =&amp;gt; amount&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; not unique, scenario A = scenario B =&amp;gt; amount else 0&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Data, copy in powerquery&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckwuKU3MUTAyMDRS0kHjGRobGhgYABm6hiAGkBmrQ0iHEVSHKRb1JijqjVFtwGaBGYoGUxQN2CwwI9kLqDrMUHUQtsIUxc+GEPWxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Scenario A" = _t, #"Scenario B" = _t, #"G/L" = _t, Amount = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Amount", type number}})
in
    #"Changed Type"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dax formula for column:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;New Amount = 
VAR CurrentScenarioGL = 'Table'[Scenario A] &amp;amp; 'Table'[G/L]
VAR CountScenarioGL =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        REMOVEFILTERS ( 'Table' ),
        'Table'[Scenario A] &amp;amp; 'Table'[G/L] = CurrentScenarioGL
    )
VAR NewAmount =
    SWITCH (
        TRUE (),
        CountScenarioGL = 1, 'Table'[Amount],
        'Table'[Scenario A] = 'Table'[Scenario B], 'Table'[Amount],
        0
    )
RETURN
    NewAmount&lt;/LI-CODE&gt;&lt;P&gt;Pay attention, 'switch' stop evaluation when first condition is met.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Hope this help.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Aug 2022 17:43:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2699281#M81600</guid>
      <dc:creator>latimeria</dc:creator>
      <dc:date>2022-08-14T17:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: New calculated column too complex for me .</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2699347#M81609</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="151306" data-lia-user-login="latimeria" class="lia-mention lia-mention-user"&gt;latimeria&lt;/a&gt;&amp;nbsp; Thank you very much . indeed this is very usefull.&lt;/P&gt;&lt;P&gt;I didn't understand yet your formula but , I will take time to understand it for sure .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I forgot to put another scenario , sorry for that .&lt;/P&gt;&lt;P&gt;in the situation below Scenario A = Actual 2017 and Scenario B = Actual 2016&amp;nbsp; NewValue&amp;nbsp; should contain the last known value when scenario A =&amp;nbsp; Scenario B&amp;nbsp;&lt;/P&gt;&lt;P&gt;the purpose of this script is to have a value for each scenario A.&lt;/P&gt;&lt;P&gt;In this situation the last value is Scenario A = Actual 2016 and Scenario B = Actual 2016&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I hope you can help me again , I cross my finger &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;paololito&lt;/P&gt;</description>
      <pubDate>Sun, 14 Aug 2022 19:25:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2699347#M81609</guid>
      <dc:creator>paololito</dc:creator>
      <dc:date>2022-08-14T19:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: New calculated column too complex for me .</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2699424#M81623</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;New Amount = 
VAR MaxScenarioBForCurrentGroup =
    CALCULATE (
        MAX ( 'Table'[Scenario B] ),
        ALLEXCEPT ( 'Table', 'Table'[Scenario A], 'Table'[G/L] )
    )
VAR NewAmount =
    // choose  expressions - both give same result
    //IF ( 'Table'[Scenario B] = MaxScenarioBForCurrentGroup, 'Table'[Amount], 0 )
    CALCULATE( SUM('Table'[Amount]), 'Table'[Scenario B] = MaxScenarioBForCurrentGroup )
RETURN
    NewAmount&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 14 Aug 2022 22:17:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2699424#M81623</guid>
      <dc:creator>latimeria</dc:creator>
      <dc:date>2022-08-14T22:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: New calculated column too complex for me .</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2700623#M81733</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="151306" data-lia-user-login="latimeria" class="lia-mention lia-mention-user"&gt;latimeria&lt;/a&gt;&amp;nbsp;It works fine&amp;nbsp; . thank you very much for your support .&lt;/P&gt;&lt;P&gt;your dax code seems be very simple &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I choose the IF expression because the other one don't give the result expected .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 14:07:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2700623#M81733</guid>
      <dc:creator>paololito</dc:creator>
      <dc:date>2022-08-15T14:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: New calculated column too complex for me .</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2710276#M82296</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="151306" data-lia-user-login="latimeria" class="lia-mention lia-mention-user"&gt;latimeria&lt;/a&gt;&amp;nbsp;, I try to understand your code .&lt;/P&gt;&lt;P&gt;Can you give me some explanation about the usage of ALLEXCEPT .&lt;/P&gt;&lt;P&gt;Normally ALLEXCEPT mean ALL (table) except filter context but I have no filter context on my table .&amp;nbsp; does it mean that when you calculate Row by Row the value of a column became a filter context ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 15:11:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2710276#M82296</guid>
      <dc:creator>paololito</dc:creator>
      <dc:date>2022-08-18T15:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: New calculated column too complex for me .</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2711761#M82412</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="368503" data-lia-user-login="paololito" class="lia-mention lia-mention-user"&gt;paololito&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Calculate works only with filters context, not with row context, so you"re right the row context is tranformed into a filter context.&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can find the explantion here:&amp;nbsp;&lt;A href="https://www.sqlbi.com/articles/understanding-context-transition-in-dax/" target="_blank" rel="noopener"&gt;Understanding context transition in DAX - SQLBI&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Steps for creating new column with calculate: (not all steps explained, there more steps) for each row:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;save the current filter context&lt;/LI&gt;&lt;LI&gt;transition the row context into filter context. basically, filter all fields with the current field's value&lt;/LI&gt;&lt;LI&gt;apply the new context, allexcept = remove (not filter added!) any active filters on all fields except&amp;nbsp; on columns Table'&lt;SPAN&gt;[Scenario A] &amp;amp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[G/L] .&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;get the max value for&amp;nbsp;&lt;/SPAN&gt;'Table'&lt;SPAN&gt;[Scenario B] in this new context, with current&amp;nbsp;&lt;/SPAN&gt;'&lt;SPAN&gt;[Scenario A]&amp;nbsp; &amp;amp; [G/L]&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;restore the current context&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;The most important thing to remind is that the evaluation happens &lt;STRONG&gt;after&lt;/STRONG&gt; filering.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;screen shot after the calculate:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;usefull links:&lt;BR /&gt;&lt;A href="https://dax.guide/allexcept/" target="_blank" rel="noopener"&gt;ALLEXCEPT – DAX Guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/introducing-calculate-in-dax/" target="_blank" rel="noopener"&gt;Introducing CALCULATE in DAX - SQLBI&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 07:28:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/New-calculated-column-too-complex-for-me/m-p/2711761#M82412</guid>
      <dc:creator>latimeria</dc:creator>
      <dc:date>2022-08-19T07:28:01Z</dc:date>
    </item>
  </channel>
</rss>

