<?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: Find the first date that hits the goal in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/2151302#M49583</link>
    <description>&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 23 Oct 2021 08:53:45 GMT</pubDate>
    <dc:creator>CNENFRNL</dc:creator>
    <dc:date>2021-10-23T08:53:45Z</dc:date>
    <item>
      <title>Find the first date that hits the goal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/2151072#M49576</link>
      <description>&lt;P&gt;I am trying to find the first date that hits the goal (100 in this case) per ID&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the sample data structure and desired output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What would be the DAX Formula for calculating the "First Date to hit the goal"?&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;</description>
      <pubDate>Fri, 22 Oct 2021 19:48:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/2151072#M49576</guid>
      <dc:creator>kangx322</dc:creator>
      <dc:date>2021-10-22T19:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Find the first date that hits the goal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/2151138#M49577</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="332753" data-lia-user-login="kangx322" class="lia-mention lia-mention-user"&gt;kangx322&lt;/a&gt;&amp;nbsp; if you have a table (called 'fact')&amp;nbsp; like this&amp;nbsp;&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;| id | date       | value |
|----|------------|-------|
| 1  | 2021-01-01 | 20    |
| 1  | 2021-01-01 | 30    |
| 1  | 2021-01-02 | 70    |
| 1  | 2021-01-02 | 40    |
| 1  | 2021-01-03 | 80    |
| 1  | 2021-01-03 | 90    |
| 2  | 2021-01-01 | 80    |
| 2  | 2021-01-02 | 40    |
| 2  | 2021-01-03 | 70    |
| 2  | 2021-01-03 | 60    |
| 2  | 2021-01-04 | 130   |&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and desire to come to this&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;You can write following two measures&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;earliestDayTargetMet = 
CALCULATE (
    MIN ( 'fact'[date] ),
    FILTER (
        'fact',
        'fact'[date]
            = CALCULATE (
                MINX (
                    FILTER (
                        ADDCOLUMNS (
                            'fact',
                            "sum",
                                CALCULATE (
                                    SUM ( 'fact'[value] ),
                                    ALLEXCEPT ( 'fact', 'fact'[id], 'fact'[date] )
                                )
                        ),
                        [sum] &amp;gt;= 100
                    ),
                    'fact'[date]
                ),
                ALLEXCEPT ( 'fact', 'fact'[id] )
            )
    )
)


sumValueOnEarliestDayTargetMet = 
CALCULATE (
    SUM ( 'fact'[value] ),
    FILTER (
        'fact',
        'fact'[date]
            = CALCULATE (
                MINX (
                    FILTER (
                        ADDCOLUMNS (
                            'fact',
                            "sum",
                                CALCULATE (
                                    SUM ( 'fact'[value] ),
                                    ALLEXCEPT ( 'fact', 'fact'[id], 'fact'[date] )
                                )
                        ),
                        [sum] &amp;gt;= 100
                    ),
                    'fact'[date]
                ),
                ALLEXCEPT ( 'fact', 'fact'[id] )
            )
    )
)&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;</description>
      <pubDate>Fri, 22 Oct 2021 21:48:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/2151138#M49577</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2021-10-22T21:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: Find the first date that hits the goal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/2151302#M49583</link>
      <description>&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Oct 2021 08:53:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/2151302#M49583</guid>
      <dc:creator>CNENFRNL</dc:creator>
      <dc:date>2021-10-23T08:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Find the first date that hits the goal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/2151398#M49589</link>
      <description>&lt;P&gt;Excel worksheet formulae are power enough to handle it with ease.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Oct 2021 12:50:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/2151398#M49589</guid>
      <dc:creator>CNENFRNL</dc:creator>
      <dc:date>2021-10-23T12:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Find the first date that hits the goal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/3246657#M119622</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="250150" data-lia-user-login="CNENFRNL" class="lia-mention lia-mention-user"&gt;CNENFRNL&lt;/a&gt;&amp;nbsp;.&lt;BR /&gt;I had the exact same problem, with the same kind of table/columns, and your solution worked fine for me.&lt;BR /&gt;The only difference is that the Target is set to 100 (fixed) and not Max(Target[target])&lt;BR /&gt;The problem is that i want the earliest date as a column, in order to use it as a filter or in the x-axis of a line chart.&amp;nbsp;&lt;BR /&gt;When i use your DAX in a calculated column i get the following error message "a circular dependency was detected".&lt;BR /&gt;&lt;BR /&gt;The exact DAX i use for the calculated column is the following:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;earliest_date_correct_column =&lt;BR /&gt;var tgt=100&lt;BR /&gt;return&lt;BR /&gt;minx(&lt;BR /&gt;filter(&lt;BR /&gt;values(Sales[date]),&lt;BR /&gt;CALCULATE(sum(Sales[value]), Sales[date]&amp;lt;= earlier ( Sales[date]))&amp;gt;= tgt),&lt;BR /&gt;Sales[date])&lt;BR /&gt;&lt;BR /&gt;Could you please help me fix it? I'm really stuck.&amp;nbsp;&lt;BR /&gt;Thanks in advance&lt;BR /&gt;Kostas&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 22 May 2023 07:02:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/3246657#M119622</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-05-22T07:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Find the first date that hits the goal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/4037425#M160042</link>
      <description>&lt;P&gt;I'm trying to do a similar situation but need to display 1 row for each ID that has hit the $200 threshold. The output needs to have 1 row for each ID, the first date (min) date the ID hit that threshold, and then a running $ total -- even if the ID hits the threshold multiple times, I just want the first date and the entire sum of that ID for a time period. I am having issues with displaying the min date if ID's have multiple check IDs that hit the $200 threshold alone.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 15:01:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/4037425#M160042</guid>
      <dc:creator>ejoyce5</dc:creator>
      <dc:date>2024-07-11T15:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Find the first date that hits the goal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/4037518#M160048</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="664222" data-lia-user-login="ejoyce5" class="lia-mention lia-mention-user"&gt;ejoyce5&lt;/a&gt;&amp;nbsp; you can use the following two measures to give you whatyou need&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;P&gt;&amp;nbsp;&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;runningTotal = 
VAR runningTotal =
    CALCULATE (
        SUM ( t1[Paid] ),
        WINDOW (
            1,
            ABS,
            0,
            REL,
            ALL ( t1[ID], t1[Date] ),
            ORDERBY ( t1[Date], ASC ),
            ,
            PARTITIONBY ( t1[ID] )
        ),
        ALL ( t1 )
    )
return runningTotal 


minDate = 
VAR mxID =
    MAX ( t1[ID] )
VAR cond =
    CALCULATE (
        MIN ( t1[Date] ),
        TOPN (
            1,
            FILTER ( ALL ( t1 ), t1[ID] = mxID &amp;amp;&amp;amp; [runningTotal] &amp;gt;= 200 ),
            t1[Date], ASC
        )
    )
RETURN
    IF ( MAX ( t1[Date] ) == cond, MAX ( t1[Date] ) )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 16:11:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/4037518#M160048</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2024-07-11T16:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: Find the first date that hits the goal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/4037626#M160058</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="24978" data-lia-user-login="smpa01" class="lia-mention lia-mention-user"&gt;smpa01&lt;/a&gt;&amp;nbsp;, but when I do that it returns the max date for each ID, not the MIN date of when the running total hit &amp;gt; $200. For ex: in my example above, the ID 1 hit &amp;gt; $200 threshold 1/3/2024 and had another check 2/2/2024 too which increases the running total, but the only thing I care about is the MIN date of when an ID hit the threshold and then display the running total overall (say the date is through 6/1/2024, and the ID hit &amp;gt; $200 threshold 1/3/2024 I would want to see the ID, date 1/3/2024, and the running total as of 6/1/2024.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 16:30:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/4037626#M160058</guid>
      <dc:creator>ejoyce5</dc:creator>
      <dc:date>2024-07-11T16:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: Find the first date that hits the goal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/4037675#M160060</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="664222" data-lia-user-login="ejoyce5" class="lia-mention lia-mention-user"&gt;ejoyce5&lt;/a&gt; refer to the attached pbix&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 16:53:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/4037675#M160060</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2024-07-11T16:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Find the first date that hits the goal</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/4044655#M160427</link>
      <description>&lt;P&gt;Thank you, this resolved my issue and I was able to solve. Curious - is there a way to get count of rows in the visual, or number of distinct IDs in the visual on the total bar? Or another way to visualize in a metric form of total number of rows in this output?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2024 17:09:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Find-the-first-date-that-hits-the-goal/m-p/4044655#M160427</guid>
      <dc:creator>ejoyce5</dc:creator>
      <dc:date>2024-07-16T17:09:51Z</dc:date>
    </item>
  </channel>
</rss>

