<?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: Calculated Column Index that Restarts from 1 Based on Values in Another Column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Index-that-Restarts-from-1-Based-on-Values-in/m-p/4271740#M169437</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thank you for your message, and it is possible.&lt;/P&gt;
&lt;P&gt;Please let me know if you have date column and time column separately in the table, or date&amp;amp;time column (combined) in the table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have the combined column in the table, it is pretty much similar to the above solution. Please try to write the same DAX formula and check whether it works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if you have separate column in the table, I tried to create a new sample like below, and please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, it would be great if you could share your sample pbix file's link, and then I can try to look into it.&lt;/P&gt;
&lt;P&gt;Thank you.&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;IndexCC = 
VAR _condition =
    ADDCOLUMNS (
        NPS,
        "@condition", IF ( NPS[NetPromoterSystem] = "Promoter", 0, 1 )
    )
VAR _group =
    ADDCOLUMNS (
        _condition,
        "@group",
            SUMX (
                FILTER ( _condition, NPS[CreatedDate]+NPS[CreatedTime] &amp;lt;= EARLIER ( NPS[CreatedDate])+EARLIER(NPS[CreatedTime]) ) ,
                [@condition]
            )
    )
VAR _index =
    ADDCOLUMNS (
        _group,
        "@index",
            SUMX (
                FILTER (
                    _group,
                    NPS[CreatedDate]+NPS[CreatedTime] &amp;lt;= EARLIER ( NPS[CreatedDate] )+EARLIER(NPS[CreatedTime])
                        &amp;amp;&amp;amp; [@group] = EARLIER ( [@group] )
                ),
                1
            )
    )
RETURN
    MAXX (
        FILTER (
            _index,
            NPS[CreatedDate]+NPS[CreatedTime] = EARLIER ( NPS[CreatedDate] )+EARLIER(NPS[CreatedTime])
                &amp;amp;&amp;amp; NPS[SurveyName] = EARLIER ( NPS[SurveyName] )
                &amp;amp;&amp;amp; NPS[NetPromoterSystem] = EARLIER ( NPS[NetPromoterSystem] )
        ),
        [@index]
    )&lt;/LI-CODE&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;
&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>Wed, 06 Nov 2024 03:54:21 GMT</pubDate>
    <dc:creator>Jihwan_Kim</dc:creator>
    <dc:date>2024-11-06T03:54:21Z</dc:date>
    <item>
      <title>Calculated Column Index that Restarts from 1 Based on Values in Another Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Index-that-Restarts-from-1-Based-on-Values-in/m-p/4269664#M169309</link>
      <description>&lt;P&gt;I am trying to create a DAX calculated column formula that sorts the rows in order based on the "CreatedDate" column and then indexes the rows starting from 1. I want to restart the Index every time the "Net Promoter System" column does not equal "Promoter".&lt;BR /&gt;&lt;BR /&gt;The below formula does not restart the index from 1. How can I adjust it?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Index =&lt;BR /&gt;VAR CurrentDate = NPS[CreatedDate]&lt;BR /&gt;VAR CurrentRowNumber = NPS[Survey Name]&lt;BR /&gt;VAR IsPromoter = NPS[Net Promoter System] = "Promoter"&lt;/P&gt;&lt;P&gt;RETURN&lt;BR /&gt;IF(&lt;BR /&gt;IsPromoter,&lt;BR /&gt;COUNTROWS(&lt;BR /&gt;FILTER(&lt;BR /&gt;NPS,&lt;BR /&gt;NPS[CreatedDate] &amp;lt;= CurrentDate &amp;amp;&amp;amp;&lt;BR /&gt;NPS[Survey Name] &amp;lt;= CurrentRowNumber &amp;amp;&amp;amp;&lt;BR /&gt;NPS[Net Promoter System] = "Promoter"&lt;BR /&gt;)&lt;BR /&gt;),&lt;BR /&gt;0&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2024 20:36:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Index-that-Restarts-from-1-Based-on-Values-in/m-p/4269664#M169309</guid>
      <dc:creator>TJK</dc:creator>
      <dc:date>2024-11-04T20:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Column Index that Restarts from 1 Based on Values in Another Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Index-that-Restarts-from-1-Based-on-Values-in/m-p/4269979#M169321</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="614480" data-lia-user-login="TJK" class="lia-mention lia-mention-user"&gt;TJK&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try the following DAX formula:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Index = 
VAR CurrentDate = NPS[CreatedDate]
VAR CurrentRowNumber = NPS[Survey Name]
VAR IsPromoter = NPS[Net Promoter System] = "Promoter"
VAR InitialIndex = RANKX(ALL(NPS), NPS[CreatedDate], , ASC, DENSE)
VAR TempTable = 
    FILTER(
        ADDCOLUMNS(
            ALL(NPS),
            "TempIndex", RANKX(
                FILTER(
                    ALL(NPS),
                    NPS[Net Promoter System] &amp;lt;&amp;gt; "Promoter"
                ),
                NPS[CreatedDate],
                ,
                ASC,
                DENSE
            )
        ),
        NPS[Net Promoter System] &amp;lt;&amp;gt; "Promoter"
    )
VAR NewIndexValue = 
    IF(
        IsPromoter,
        InitialIndex,
        MAXX(
            FILTER(
                TempTable,
                NPS[CreatedDate] = CurrentDate &amp;amp;&amp;amp;
                NPS[Survey Name] = CurrentRowNumber
            ),
            [TempIndex]
        )
    )
RETURN
NewIndexValue&lt;/LI-CODE&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;P&gt;Best Regards,&lt;BR /&gt;Jarvis Tang&lt;BR /&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 03:14:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Index-that-Restarts-from-1-Based-on-Values-in/m-p/4269979#M169321</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-05T03:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Column Index that Restarts from 1 Based on Values in Another Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Index-that-Restarts-from-1-Based-on-Values-in/m-p/4270031#M169325</link>
      <description>&lt;P&gt;Hi,&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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;IndexCC =
VAR _condition =
    ADDCOLUMNS (
        NPS,
        "@condition", IF ( NPS[NetPromoterSystem] = "Promoter", 0, 1 )
    )
VAR _group =
    ADDCOLUMNS (
        _condition,
        "@group",
            SUMX (
                FILTER ( _condition, NPS[CreatedDate] &amp;lt;= EARLIER ( NPS[CreatedDate] ) ),
                [@condition]
            )
    )
VAR _index =
    ADDCOLUMNS (
        _group,
        "@index",
            SUMX (
                FILTER (
                    _group,
                    NPS[CreatedDate] &amp;lt;= EARLIER ( NPS[CreatedDate] )
                        &amp;amp;&amp;amp; [@group] = EARLIER ( [@group] )
                ),
                1
            )
    )
RETURN
    MAXX (
        FILTER (
            _index,
            NPS[CreatedDate] = EARLIER ( NPS[CreatedDate] )
                &amp;amp;&amp;amp; NPS[SurveyName] = EARLIER ( NPS[SurveyName] )
                &amp;amp;&amp;amp; NPS[NetPromoterSystem] = EARLIER ( NPS[NetPromoterSystem] )
        ),
        [@index]
    )
&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 05 Nov 2024 04:29:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Index-that-Restarts-from-1-Based-on-Values-in/m-p/4270031#M169325</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2024-11-05T04:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Column Index that Restarts from 1 Based on Values in Another Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Index-that-Restarts-from-1-Based-on-Values-in/m-p/4270748#M169363</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your response. You understood correctly, and your output is perfect. However, I have "Other" values that show up on the same day as "Promoter". Is it possible to incorporate time as well?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 13:06:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Index-that-Restarts-from-1-Based-on-Values-in/m-p/4270748#M169363</guid>
      <dc:creator>TJK</dc:creator>
      <dc:date>2024-11-05T13:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated Column Index that Restarts from 1 Based on Values in Another Column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Index-that-Restarts-from-1-Based-on-Values-in/m-p/4271740#M169437</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Thank you for your message, and it is possible.&lt;/P&gt;
&lt;P&gt;Please let me know if you have date column and time column separately in the table, or date&amp;amp;time column (combined) in the table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have the combined column in the table, it is pretty much similar to the above solution. Please try to write the same DAX formula and check whether it works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if you have separate column in the table, I tried to create a new sample like below, and please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, it would be great if you could share your sample pbix file's link, and then I can try to look into it.&lt;/P&gt;
&lt;P&gt;Thank you.&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;IndexCC = 
VAR _condition =
    ADDCOLUMNS (
        NPS,
        "@condition", IF ( NPS[NetPromoterSystem] = "Promoter", 0, 1 )
    )
VAR _group =
    ADDCOLUMNS (
        _condition,
        "@group",
            SUMX (
                FILTER ( _condition, NPS[CreatedDate]+NPS[CreatedTime] &amp;lt;= EARLIER ( NPS[CreatedDate])+EARLIER(NPS[CreatedTime]) ) ,
                [@condition]
            )
    )
VAR _index =
    ADDCOLUMNS (
        _group,
        "@index",
            SUMX (
                FILTER (
                    _group,
                    NPS[CreatedDate]+NPS[CreatedTime] &amp;lt;= EARLIER ( NPS[CreatedDate] )+EARLIER(NPS[CreatedTime])
                        &amp;amp;&amp;amp; [@group] = EARLIER ( [@group] )
                ),
                1
            )
    )
RETURN
    MAXX (
        FILTER (
            _index,
            NPS[CreatedDate]+NPS[CreatedTime] = EARLIER ( NPS[CreatedDate] )+EARLIER(NPS[CreatedTime])
                &amp;amp;&amp;amp; NPS[SurveyName] = EARLIER ( NPS[SurveyName] )
                &amp;amp;&amp;amp; NPS[NetPromoterSystem] = EARLIER ( NPS[NetPromoterSystem] )
        ),
        [@index]
    )&lt;/LI-CODE&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;
&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>Wed, 06 Nov 2024 03:54:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-Column-Index-that-Restarts-from-1-Based-on-Values-in/m-p/4271740#M169437</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2024-11-06T03:54:21Z</dc:date>
    </item>
  </channel>
</rss>

