<?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: Power BI calculated table, new column that adds 1 to previous row value based on condition in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-calculated-table-new-column-that-adds-1-to-previous-row/m-p/3264945#M120836</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thank you for your message, and please try something like below.&lt;/P&gt;
&lt;P&gt;&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;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Expected result newe column CC = 
VAR _startrow =
    MINX( FILTER( Data, Data[Cust ID] = EARLIER( Data[Cust ID])), Data[PickUp Date] )
VAR _addcolumn =
    ADDCOLUMNS (
        Data,
        "@condition",
            SWITCH (
                TRUE (),
                Data[PickUp Date] = _startrow, 1,
                DATEDIFF ( Data[Next Pickup], Data[PickUp Date], DAY ) &amp;gt; 90, 1,
                0
            )
    )
RETURN
    SUMX (
        FILTER (
            _addcolumn,
            Data[PickUp Date] &amp;lt;= EARLIER ( Data[PickUp Date] )
                &amp;amp;&amp;amp; Data[Cust ID] = EARLIER ( Data[Cust ID] )
        ),
        [@condition]
    )&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 02 Jun 2023 03:19:20 GMT</pubDate>
    <dc:creator>Jihwan_Kim</dc:creator>
    <dc:date>2023-06-02T03:19:20Z</dc:date>
    <item>
      <title>Power BI calculated table, new column that adds 1 to previous row value based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-calculated-table-new-column-that-adds-1-to-previous-row/m-p/3264296#M120806</link>
      <description>&lt;P&gt;Hello: I'm new to Power BI and need a little help. I have searched for what I'm trying to accomplish but haven't quite found a suitable solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a calculated table in Power BI. I'm trying to create a New Column that does the following: If the difference between pickup and next pickup is &amp;gt;90 then previous row value + 1, or else previous row value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New Column = IF('TABLE_All Data Combined'[Days Between Pickup &amp;amp; NextPickup]&amp;gt; 90,"Prev Row Value + 1","Prev Row Value")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is an example of what I would the results to look like. Any help would be greatly appreciated&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 15:37:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-calculated-table-new-column-that-adds-1-to-previous-row/m-p/3264296#M120806</guid>
      <dc:creator>LindaO713</dc:creator>
      <dc:date>2023-06-01T15:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI calculated table, new column that adds 1 to previous row value based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-calculated-table-new-column-that-adds-1-to-previous-row/m-p/3264488#M120814</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Expected result newe column CC =
VAR _startrow =
    MIN ( Data[PickUp Date] )
VAR _addcolumn =
    ADDCOLUMNS (
        Data,
        "@condition",
            SWITCH (
                TRUE (),
                Data[PickUp Date] = _startrow, 1,
                DATEDIFF ( Data[Next Pickup], Data[PickUp Date], DAY ) &amp;gt; 90, 1,
                0
            )
    )
RETURN
    SUMX (
        FILTER (
            _addcolumn,
            Data[PickUp Date] &amp;lt;= EARLIER ( Data[PickUp Date] )
                &amp;amp;&amp;amp; Data[Cust ID] = EARLIER ( Data[Cust ID] )
        ),
        [@condition]
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 17:48:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-calculated-table-new-column-that-adds-1-to-previous-row/m-p/3264488#M120814</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2023-06-01T17:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI calculated table, new column that adds 1 to previous row value based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-calculated-table-new-column-that-adds-1-to-previous-row/m-p/3264701#M120826</link>
      <description>&lt;P&gt;Hi Jihwan - THANK YOU so much!!!! This almost works! However, I failed to mention that this table has many customers, so I need it to start at 1 for min pickup date for each customer (hope below in "Expected Cust Grouping" column helps demonstate what I'm looking to do)&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 22:50:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-calculated-table-new-column-that-adds-1-to-previous-row/m-p/3264701#M120826</guid>
      <dc:creator>LindaO713</dc:creator>
      <dc:date>2023-06-01T22:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI calculated table, new column that adds 1 to previous row value based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-calculated-table-new-column-that-adds-1-to-previous-row/m-p/3264945#M120836</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thank you for your message, and please try something like below.&lt;/P&gt;
&lt;P&gt;&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;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Expected result newe column CC = 
VAR _startrow =
    MINX( FILTER( Data, Data[Cust ID] = EARLIER( Data[Cust ID])), Data[PickUp Date] )
VAR _addcolumn =
    ADDCOLUMNS (
        Data,
        "@condition",
            SWITCH (
                TRUE (),
                Data[PickUp Date] = _startrow, 1,
                DATEDIFF ( Data[Next Pickup], Data[PickUp Date], DAY ) &amp;gt; 90, 1,
                0
            )
    )
RETURN
    SUMX (
        FILTER (
            _addcolumn,
            Data[PickUp Date] &amp;lt;= EARLIER ( Data[PickUp Date] )
                &amp;amp;&amp;amp; Data[Cust ID] = EARLIER ( Data[Cust ID] )
        ),
        [@condition]
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 02 Jun 2023 03:19:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-calculated-table-new-column-that-adds-1-to-previous-row/m-p/3264945#M120836</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2023-06-02T03:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Power BI calculated table, new column that adds 1 to previous row value based on condition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-calculated-table-new-column-that-adds-1-to-previous-row/m-p/3265640#M120881</link>
      <description>&lt;P&gt;Jihwan!!! Thank you so much for all your help, this works perfectly!!! I thought I needed to change the VAR startrow to Minx(Filter, but was playing around with it for a while and couldn't figure it out. Your help is greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 12:37:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Power-BI-calculated-table-new-column-that-adds-1-to-previous-row/m-p/3265640#M120881</guid>
      <dc:creator>LindaO713</dc:creator>
      <dc:date>2023-06-02T12:37:34Z</dc:date>
    </item>
  </channel>
</rss>

