<?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: Complex Conditional Calculation Formula in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-Conditional-Calculation-Formula/m-p/3545943#M136337</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="636377" data-lia-user-login="LABrowne" class="lia-mention lia-mention-user"&gt;LABrowne&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please try below dax formula:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;V2 Net Sales = 
   SUMX(
       VALUES(AdjustmentType[AdjustmentTypeId]),
       IF(
           MAX(Contract[ContractTable]) = 22,
           ([Net Sales] / [Order Period]) * [Days Since Order],
           SWITCH(
               AdjustmentType[AdjustmentTypeId],
               2, [V1 Gross Tax Sales],
               1, [V1 Net Before Tax Sales],
               3, [V1 Net Before Tax Sales],
               4, [V1 Net Before Tax Sales],
               5, [V1 Net Before Tax Sales]
           )
       )
   )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;BR /&gt;Community Support Team_Binbin Yu&lt;BR /&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Nov 2023 03:12:50 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-11-22T03:12:50Z</dc:date>
    <item>
      <title>Complex Conditional Calculation Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-Conditional-Calculation-Formula/m-p/3542148#M136143</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following dax code:&lt;/P&gt;&lt;P&gt;(1)&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;V2 Net Sales =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SUMX&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;VALUES&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;AdjustmentType&lt;/SPAN&gt;&lt;SPAN&gt;[AdjustmentTypeId]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;SWITCH&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;AdjustmentType&lt;/SPAN&gt;&lt;SPAN&gt;[AdjustmentTypeId]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[V1 Gross Tax Sales]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[V1 Net Before Tax Sales]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;3&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[V1 Net Before Tax Sales]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;4&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[V1 Net Before Tax Sales]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;[V1 Net Before Tax Sales]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I need to build in another condition that if (2) Contract[ContractTable] = 22, then it has to use the following formula:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;([Net Sales] / [Order Period]) * [Days Since Order]).&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;For all other contracts it should follow (1) though.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Any help would be great.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 20 Nov 2023 10:17:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-Conditional-Calculation-Formula/m-p/3542148#M136143</guid>
      <dc:creator>LABrowne</dc:creator>
      <dc:date>2023-11-20T10:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Conditional Calculation Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-Conditional-Calculation-Formula/m-p/3542207#M136148</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Certainly! To incorporate the additional condition you mentioned, you can modify your DAX code as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;V2 Net Sales =&lt;BR /&gt;SUMX(&lt;BR /&gt;VALUES(AdjustmentType[AdjustmentTypeId], Contract[ContractTable]),&lt;BR /&gt;IF(&lt;BR /&gt;Contract[ContractTable] = 22,&lt;BR /&gt;([Net Sales] / [Order Period]) * [Days Since Order],&lt;BR /&gt;SWITCH(&lt;BR /&gt;AdjustmentType[AdjustmentTypeId],&lt;BR /&gt;2, [V1 Gross Tax Sales],&lt;BR /&gt;1, [V1 Net Before Tax Sales],&lt;BR /&gt;3, [V1 Net Before Tax Sales],&lt;BR /&gt;4, [V1 Net Before Tax Sales],&lt;BR /&gt;5, [V1 Net Before Tax Sales]&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In this modified code, I added the Contract[ContractTable] to the VALUES function, and I used an IF statement to check if the contract is equal to 22. If it is, then it uses the formula you provided; otherwise, it uses the SWITCH statement as before. This should achieve the desired behavior based on the specified conditions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 10:40:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-Conditional-Calculation-Formula/m-p/3542207#M136148</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-11-20T10:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Conditional Calculation Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-Conditional-Calculation-Formula/m-p/3542346#M136159</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your response but it's not letting me have 2 columns for the VALUES bit only 1 column is allowed?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 11:43:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-Conditional-Calculation-Formula/m-p/3542346#M136159</guid>
      <dc:creator>LABrowne</dc:creator>
      <dc:date>2023-11-20T11:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Conditional Calculation Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-Conditional-Calculation-Formula/m-p/3545943#M136337</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="636377" data-lia-user-login="LABrowne" class="lia-mention lia-mention-user"&gt;LABrowne&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please try below dax formula:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;V2 Net Sales = 
   SUMX(
       VALUES(AdjustmentType[AdjustmentTypeId]),
       IF(
           MAX(Contract[ContractTable]) = 22,
           ([Net Sales] / [Order Period]) * [Days Since Order],
           SWITCH(
               AdjustmentType[AdjustmentTypeId],
               2, [V1 Gross Tax Sales],
               1, [V1 Net Before Tax Sales],
               3, [V1 Net Before Tax Sales],
               4, [V1 Net Before Tax Sales],
               5, [V1 Net Before Tax Sales]
           )
       )
   )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;BR /&gt;Community Support Team_Binbin Yu&lt;BR /&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2023 03:12:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-Conditional-Calculation-Formula/m-p/3545943#M136337</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-11-22T03:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Conditional Calculation Formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-Conditional-Calculation-Formula/m-p/3546195#M136349</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I see, if you're encountering an issue with having multiple columns in the &lt;/SPAN&gt;VALUES&lt;SPAN&gt; function, you can modify the code to use a combination of &lt;/SPAN&gt;CALCULATETABLE&lt;SPAN&gt; and &lt;/SPAN&gt;FILTER&lt;SPAN&gt;. Here's an updated version of the code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;V2 Net Sales =&lt;BR /&gt;SUMX(&lt;BR /&gt;VALUES(AdjustmentType[AdjustmentTypeId]),&lt;BR /&gt;SWITCH(&lt;BR /&gt;TRUE(),&lt;BR /&gt;AdjustmentType[AdjustmentTypeId] = 2, [V1 Gross Tax Sales],&lt;BR /&gt;AdjustmentType[AdjustmentTypeId] = 1,&lt;BR /&gt;IF (&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS(&lt;BR /&gt;FILTER(&lt;BR /&gt;Contract,&lt;BR /&gt;Contract[ContractTable] = 22&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;) &amp;gt; 0,&lt;BR /&gt;([V1 Net Before Tax Sales] / [Order Period]) * [Days Since Order],&lt;BR /&gt;[V1 Net Before Tax Sales]&lt;BR /&gt;),&lt;BR /&gt;AdjustmentType[AdjustmentTypeId] = 3, [V1 Net Before Tax Sales],&lt;BR /&gt;AdjustmentType[AdjustmentTypeId] = 4, [V1 Net Before Tax Sales],&lt;BR /&gt;AdjustmentType[AdjustmentTypeId] = 5, [V1 Net Before Tax Sales],&lt;BR /&gt;BLANK()&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In this version, I've used CALCULATE along with COUNTROWS and FILTER to check if there is any row in the Contract table where ContractTable is equal to 22. If true, it applies the specified formula; otherwise, it uses [V1 Net Before Tax Sales]. Adjust the column and table names as needed based on your data model.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If this post&amp;nbsp;helps, then please consider&amp;nbsp;Accepting it as the solution&amp;nbsp;to help the other members find it more quickly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case there is still a problem, please feel free and explain your issue in detail,&amp;nbsp;It will be my pleasure to assist you in any way I can.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2023 07:26:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Complex-Conditional-Calculation-Formula/m-p/3546195#M136349</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-11-22T07:26:55Z</dc:date>
    </item>
  </channel>
</rss>

