<?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: Help DAX - conditional calculate in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-DAX-conditional-calculate/m-p/4273724#M169543</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="698337" data-lia-user-login="yoa380" class="lia-mention lia-mention-user"&gt;yoa380&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Can you please use this and check does it works in the scenario you mentioned.&lt;/P&gt;&lt;P&gt;DAX:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;V_TOTAL QTY_NEW =
VAR selectedpicture = SELECTEDVALUE(SELECT_PIC[ShortDate])
RETURN
    CALCULATE(
        SUMX(
            PROJECTION,
            PROJECTION[TOTAL QTY] *
            IF(
                YEAR(PROJECTION[PROJECTION DATE]) &amp;lt;= YEAR(TODAY()),
                RELATED(WAC[COST]),        -- Use WAC cost if projection date is in the current year or earlier
                RELATED(BUD[COST])         -- Use BUD cost if projection date is in the future
            )
        ),
        PROJECTION[PICTURE DATE] = selectedpicture
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This measure (V_TOTAL QTY_NEW) will dynamically adjust based on the year of PROJECTION DATE and multiply TOTAL QTY by either WAC or BUD cost as specified.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution, this will help others!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If my response(s) assisted you in any way, don't forget to drop me a "&lt;STRONG&gt;Kudos&lt;/STRONG&gt;" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;BR /&gt;Poojara.&lt;BR /&gt;Data Analyst | MSBI Developer | Power BI Consultant&lt;/P&gt;</description>
    <pubDate>Thu, 07 Nov 2024 09:24:16 GMT</pubDate>
    <dc:creator>Poojara_D12</dc:creator>
    <dc:date>2024-11-07T09:24:16Z</dc:date>
    <item>
      <title>Help DAX - conditional calculate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-DAX-conditional-calculate/m-p/4272736#M169493</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;I need your help for my below need. Here the explanations :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To make it simpler, let's say I have 1 fact table called "PROJECTION" in which I project the stock of my components. In the attached picture I only have 2 components A &amp;amp; B.&lt;/P&gt;&lt;P&gt;Every month I take "a picture" of this data in my ERP and thanks to Query I combine all pictures in the PROJECTION table.&lt;/P&gt;&lt;P&gt;The column "PICTURE DATE" is the month I have extracted the data (here only OCT24 &amp;amp; NOV24). In each picture, we project for each item a quantity available and a quantity blocked AND for each end of coming months (that are in column "PROJECTION DATE").&lt;/P&gt;&lt;P&gt;I already created a DAX measure called "TOTAL QTY" as per :&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;TOTAL QTY =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUMX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;PROJECTION&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;PROJECTION&lt;/SPAN&gt;&lt;SPAN&gt;[QTY ava]&lt;/SPAN&gt;&lt;SPAN&gt;+&lt;/SPAN&gt;&lt;SPAN&gt;PROJECTION&lt;/SPAN&gt;&lt;SPAN&gt;[QTY blk]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Then I have 2 dimension tables containing items costs. One table "WAC" contains for each item their weighted average cost and The other "BUD" contains for each item their budget cost.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;In my final report, I let the user select the PROJECTION picture he wants through a segment call "SELECT_PIC". And in a matrix I put items in lines and Year/Month of PROJECTION DATE in columns.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;The value in the matrix is the valuation of items stock. Until now I was valuating my TOTAL QTY with only the cost of WAC table. &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;Cost that I also integrated in my fact table as "COST_WAC" through a new column (possible thanks to a relationship between tables)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;COST_WAC = &lt;/SPAN&gt;&lt;SPAN&gt;RELATED&lt;/SPAN&gt;&lt;SPAN&gt;(WAC[COST])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;My measure was :&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;V_TOTAL QTY =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;selectedpicture&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;SELECTEDVALUE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SELECT_PIC&lt;/SPAN&gt;&lt;SPAN&gt;[ShortDate]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;SUMX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;PROJECTION&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;PROJECTION&lt;/SPAN&gt;&lt;SPAN&gt;[TOTAL QTY]&lt;/SPAN&gt;&lt;SPAN&gt;*&lt;/SPAN&gt;&lt;SPAN&gt;PROJECTION&lt;/SPAN&gt;&lt;SPAN&gt;[COST_WAC]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;PROJECTION&lt;/SPAN&gt;&lt;SPAN&gt;[PICTURE DATE]&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;selectedpicture&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;My new need for which I need your help is that I want to introduce a IF condition kind of logic somewhere.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;We will still select a PICTURE DATE on the report but the valuation of stock should now be dependent of "PROJECTION DATE".&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;If I select PICTURE DATE = 01/11/2024 for my attached example it's the blue lines that will be taken. My matrix will display 3 columns PROJECTION DATE = 11/2024, 12/2024 and 01/2025. &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;My ne&lt;/SPAN&gt;&lt;SPAN&gt;w valuation (let's call V_TOTAL QTY_NEW) should multiply the TOTAL QTY by the cost of the item from the WAC cost table if YEAR(PROJECTION DATE) &amp;lt;= YEAR(NOW)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;should mutiply TOTAL QTY by the cost of the item from the BUD cost table if YEAR(PROJECTION DATE) &amp;gt; YEAR(NOW)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 06 Nov 2024 15:42:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-DAX-conditional-calculate/m-p/4272736#M169493</guid>
      <dc:creator>yoa380</dc:creator>
      <dc:date>2024-11-06T15:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Help DAX - conditional calculate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-DAX-conditional-calculate/m-p/4272913#M169501</link>
      <description>&lt;P&gt;hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="698337" data-lia-user-login="yoa380" class="lia-mention lia-mention-user"&gt;yoa380&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;try like:&lt;/P&gt;
&lt;P&gt;V_TOTAL QTY_NEW =&lt;/P&gt;
&lt;P&gt;VAR selectedpicture = SELECTEDVALUE(SELECT_PIC[ShortDate])&lt;/P&gt;
&lt;P&gt;RETURN&lt;/P&gt;
&lt;P&gt;IF(&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; YEAR(PROJECTION DATE) &amp;lt;= YEAR(TODAY()),&lt;/P&gt;
&lt;P&gt;CALCULATE(&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; SUMX(&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PROJECTION,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PROJECTION[TOTAL QTY]*PROJECTION[COST_WAC]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; ),&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; PROJECTION[PICTURE DATE]=selectedpicture&lt;/P&gt;
&lt;P&gt;),&lt;/P&gt;
&lt;P&gt;CALCULATE(&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; SUMX(&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PROJECTION,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PROJECTION[TOTAL QTY]*RELATED(BUD[COST_BUD]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; ),&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; PROJECTION[PICTURE DATE]=selectedpicture&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 18:53:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-DAX-conditional-calculate/m-p/4272913#M169501</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2024-11-06T18:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Help DAX - conditional calculate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-DAX-conditional-calculate/m-p/4273678#M169538</link>
      <description>&lt;P&gt;Hello, thanks for quick reply. I cannot do that, first when I type IF( YEAR( ... it doesn't offer the choice to put PROJECTION DATE. It only shows measures from the table, not the other simple columns.&lt;/P&gt;&lt;P&gt;And if I force the formula with it, it will tell me :&amp;nbsp;&lt;SPAN&gt;impossible to determine a unique value for the "projection date" column in the table. This can happen when a measurement formula refers to a column that contains many values, without specifying an aggregation such as min, max, count or sum to get a unique result.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 08:49:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-DAX-conditional-calculate/m-p/4273678#M169538</guid>
      <dc:creator>yoa380</dc:creator>
      <dc:date>2024-11-07T08:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: Help DAX - conditional calculate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-DAX-conditional-calculate/m-p/4273698#M169540</link>
      <description>&lt;P&gt;I think I found the solution, hope it will be stable ....&lt;/P&gt;&lt;P&gt;I use filters of calculate and do +&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;V_TOTAL QTY_NEW =&lt;/P&gt;&lt;P&gt;VAR selectedpicture = SELECTEDVALUE(SELECT_PIC[ShortDate])&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;CALCULATE(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; SUMX(PROJECTION,&amp;nbsp;PROJECTION[TOTAL QTY]*PROJECTION[COST_WAC]),&amp;nbsp;PROJECTION[PICTURE DATE]=selectedpicture, YEAR(PROJECTION DATE)&amp;lt;=YEAR(TODAY())) +&lt;/P&gt;&lt;P&gt;SUMX(PROJECTION,&amp;nbsp;PROJECTION[TOTAL QTY]*PROJECTION[COST_BUD]),&amp;nbsp;PROJECTION[PICTURE DATE]=selectedpicture, YEAR(PROJECTION DATE)&amp;gt;YEAR(TODAY()))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 09:10:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-DAX-conditional-calculate/m-p/4273698#M169540</guid>
      <dc:creator>yoa380</dc:creator>
      <dc:date>2024-11-07T09:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help DAX - conditional calculate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-DAX-conditional-calculate/m-p/4273724#M169543</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="698337" data-lia-user-login="yoa380" class="lia-mention lia-mention-user"&gt;yoa380&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Can you please use this and check does it works in the scenario you mentioned.&lt;/P&gt;&lt;P&gt;DAX:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;V_TOTAL QTY_NEW =
VAR selectedpicture = SELECTEDVALUE(SELECT_PIC[ShortDate])
RETURN
    CALCULATE(
        SUMX(
            PROJECTION,
            PROJECTION[TOTAL QTY] *
            IF(
                YEAR(PROJECTION[PROJECTION DATE]) &amp;lt;= YEAR(TODAY()),
                RELATED(WAC[COST]),        -- Use WAC cost if projection date is in the current year or earlier
                RELATED(BUD[COST])         -- Use BUD cost if projection date is in the future
            )
        ),
        PROJECTION[PICTURE DATE] = selectedpicture
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This measure (V_TOTAL QTY_NEW) will dynamically adjust based on the year of PROJECTION DATE and multiply TOTAL QTY by either WAC or BUD cost as specified.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Did I answer your question? Mark my post as a solution, this will help others!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If my response(s) assisted you in any way, don't forget to drop me a "&lt;STRONG&gt;Kudos&lt;/STRONG&gt;" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;BR /&gt;Poojara.&lt;BR /&gt;Data Analyst | MSBI Developer | Power BI Consultant&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 09:24:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-DAX-conditional-calculate/m-p/4273724#M169543</guid>
      <dc:creator>Poojara_D12</dc:creator>
      <dc:date>2024-11-07T09:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help DAX - conditional calculate</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-DAX-conditional-calculate/m-p/4273752#M169546</link>
      <description>&lt;P&gt;Yes, it seems to work thanks ! same result as my previous addition but shorter DAX&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 09:37:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-DAX-conditional-calculate/m-p/4273752#M169546</guid>
      <dc:creator>yoa380</dc:creator>
      <dc:date>2024-11-07T09:37:34Z</dc:date>
    </item>
  </channel>
</rss>

