<?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 DAX for value from previous month different column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-value-from-previous-month-different-column/m-p/4421377#M175537</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for a DAX or an advice on:&lt;/P&gt;&lt;P&gt;- how to get the current Stock value in February (column D, the table has no date column) showing no balance for all the previuos months.&lt;/P&gt;&lt;P&gt;- how to get the current Stock value in March (2404,08) that is the net inventory of February (column H). The Net inventory is the sum of Stock Quantity + Quantity - KG Ordered) and replicate this month after month.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Feb 2025 07:34:37 GMT</pubDate>
    <dc:creator>AAndreeea</dc:creator>
    <dc:date>2025-02-21T07:34:37Z</dc:date>
    <item>
      <title>DAX for value from previous month different column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-value-from-previous-month-different-column/m-p/4421377#M175537</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for a DAX or an advice on:&lt;/P&gt;&lt;P&gt;- how to get the current Stock value in February (column D, the table has no date column) showing no balance for all the previuos months.&lt;/P&gt;&lt;P&gt;- how to get the current Stock value in March (2404,08) that is the net inventory of February (column H). The Net inventory is the sum of Stock Quantity + Quantity - KG Ordered) and replicate this month after month.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2025 07:34:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-value-from-previous-month-different-column/m-p/4421377#M175537</guid>
      <dc:creator>AAndreeea</dc:creator>
      <dc:date>2025-02-21T07:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: DAX for value from previous month different column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-value-from-previous-month-different-column/m-p/4421400#M175538</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="936225" data-lia-user-login="AAndreeea" class="lia-mention lia-mention-user"&gt;AAndreeea&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please &lt;U&gt;provide sample data that &lt;STRONG&gt;fully&lt;/STRONG&gt; represents your issue or question in a &lt;STRONG&gt;usable format&lt;/STRONG&gt;&lt;/U&gt;, rather than a screenshot? Ensure the dataset is anonymized and does not contain any sensitive or unrelated information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally, it would be very helpful if you could &lt;U&gt;share the &lt;STRONG&gt;expected outcome&lt;/STRONG&gt; based on the provided data&lt;/U&gt; - this can be in any format, including a screenshot. Having a clear reference for comparison will significantly improve the chances of getting the correct solution in the first response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For best practices, you may find the following links useful:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank" rel="noopener"&gt;Need help uploading data?&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank" rel="noopener"&gt;Want faster answers?&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Udit&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2025 07:41:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-value-from-previous-month-different-column/m-p/4421400#M175538</guid>
      <dc:creator>quantumudit</dc:creator>
      <dc:date>2025-02-21T07:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: DAX for value from previous month different column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-value-from-previous-month-different-column/m-p/4422102#M175562</link>
      <description>&lt;P&gt;Hi there!&lt;/P&gt;&lt;P&gt;If I understand correctly, you need a DAX formula that will carry Forward Previous Month’s Stock and Calculate Net Inventory in Power BI. Here's what you could use:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;Use this DAX measure to get the previous month’s stock dynamically:&lt;/P&gt;&lt;P&gt;PreviousMonthStock =&lt;BR /&gt;VAR PrevMonth = MAX('Table'[Month_Num]) - 1&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM('Table'[Stock Quantity]),&lt;BR /&gt;FILTER('Table', 'Table'[Month_Num] = PrevMonth)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;To ensure Net Inventory carries forward each month, use:&lt;/P&gt;&lt;P&gt;Net_Inventory =&lt;BR /&gt;VAR PrevInventory =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM('Table'[Net Inventory]),&lt;BR /&gt;FILTER('Table', 'Table'[Month_Num] = MAX('Table'[Month_Num]) - 1)&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;IF(&lt;BR /&gt;ISBLANK(PrevInventory),&lt;BR /&gt;SUM('Table'[Stock Quantity]) + SUM('Table'[Quantity]) - SUM('Table'[KG Ordered]),&lt;BR /&gt;PrevInventory + SUM('Table'[Stock Quantity]) + SUM('Table'[Quantity]) - SUM('Table'[KG Ordered])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These two formulas should retrieves the stock quantity of the previous month and&amp;nbsp;find data where the month is one less than the current. It will also&amp;nbsp;check if there is any previous month's inventory, if no previous month exists, it calculates the current stock value normally. Otherwise, it adds the previous inventory and calculates the new stock level.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps you!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2025 14:09:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-value-from-previous-month-different-column/m-p/4422102#M175562</guid>
      <dc:creator>freginier</dc:creator>
      <dc:date>2025-02-21T14:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: DAX for value from previous month different column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-value-from-previous-month-different-column/m-p/4423898#M175623</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="936225" data-lia-user-login="AAndreeea" class="lia-mention lia-mention-user"&gt;AAndreeea&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here I create a Calendar table to help calculation.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Calendar =
SUMMARIZE (
    ADDCOLUMNS (
        CALENDAR ( DATE ( 2025, 01, 01 ), DATE ( 2025, 12, 31 ) ),
        "Year", YEAR ( [Date] ),
        "MONTHNAME", FORMAT ( [Date], "MMMM" ),
        "Order",
            YEAR ( [Date] ) * 100
                + MONTH ( [Date] ),
        "KeyWord", COMBINEVALUES ( "-", YEAR ( [Date] ), FORMAT ( [Date], "MMMM" ) )
    ),
    [Year],
    [MONTHNAME],
    [KeyWord],
    [Order]
)
&lt;/LI-CODE&gt;
&lt;P&gt;Add a Keyword column in your table.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;KeyWord = COMBINEVALUES("-",[Calendar_Year],[Month_Name])&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Relationship:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Measures:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Stock Quantity = 
IF (
    MAX ( 'Calendar'[Order] ) = 202502,
    5896.80,
    IF (
        MAX ( 'Calendar'[Order] ) &amp;gt; 202502,
        CALCULATE (
            SUM ( 'Table'[Quantity] ) - SUM ( 'Table'[KG Ordered] ),
            FILTER (
                ALLSELECTED ( 'Calendar' ),
                'Calendar'[Order] &amp;lt; MAX ( 'Calendar'[Order] )
            )
        ) + 5896.80
    )
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Net Inventory = 
VAR _RunningTotal = 
CALCULATE (
        SUM ( 'Table'[Quantity] ) - SUM ( 'Table'[KG Ordered] ),
        FILTER (
            ALLSELECTED ( 'Calendar' ),
            'Calendar'[Order] &amp;lt;= MAX ( 'Calendar'[Order] )
        )
    ) + 5896.80
RETURN
IF(HASONEVALUE('Calendar'[Order]),
IF (
    MAX ( 'Calendar'[Order] ) &amp;gt;= 202502,
    _RunningTotal,
    CALCULATE ( SUM ( 'Table'[Quantity] ) - SUM ( 'Table'[KG Ordered] ) )
),
_RunningTotal - CALCULATE ( SUM ( 'Table'[Quantity] ) - SUM ( 'Table'[KG Ordered] ),'Calendar'[Order] = 202501)
)
&lt;/LI-CODE&gt;
&lt;P&gt;Result is as below.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2025 05:28:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-for-value-from-previous-month-different-column/m-p/4423898#M175623</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-02-24T05:28:52Z</dc:date>
    </item>
  </channel>
</rss>

