<?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: Calculate &amp;quot;Longest Period&amp;quot; to complete a trend chart with some textual insights in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-quot-Longest-Period-quot-to-complete-a-trend-chart/m-p/3495140#M133891</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not 100% sure if it is seen only by myself, but I see the below when I click the link.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Oct 2023 02:44:27 GMT</pubDate>
    <dc:creator>Jihwan_Kim</dc:creator>
    <dc:date>2023-10-25T02:44:27Z</dc:date>
    <item>
      <title>Calculate "Longest Period" to complete a trend chart with some textual insights</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-quot-Longest-Period-quot-to-complete-a-trend-chart/m-p/3494858#M133876</link>
      <description>&lt;P&gt;Dear PBI experts,&lt;/P&gt;&lt;P&gt;I have a challenge that I simplified as per below screenshot (and here's the&amp;nbsp;&lt;STRONG&gt;&lt;A title="gantt_chart_periods.pbix" href="https://drive.google.com/file/d/17OUm-wP_jRO7_NeUYX3LJrmAmZEMO4pE/view?usp=drive_link" target="_blank" rel="noopener"&gt;gantt_chart_periods.pbix&lt;/A&gt;&amp;nbsp;&lt;/STRONG&gt;as well as the source excel file&amp;nbsp;&lt;STRONG&gt;&lt;A href="https://docs.google.com/spreadsheets/d/1TbmCLLNyzRvxGRhzRbghORGeiiWIuD-y/edit?usp=drive_link&amp;amp;ouid=116139401274371959844&amp;amp;rtpof=true&amp;amp;sd=true" target="_self"&gt;gantt_sample.xlsx&lt;/A&gt;&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;So: let's imagine you have a trend chart of "&lt;EM&gt;number of tickets per day&lt;/EM&gt;", and we want to give 2 insights to our end-users : the "&lt;FONT color="#FF0000"&gt;&lt;EM&gt;Longest Period with Ticket&lt;/EM&gt;&lt;/FONT&gt;" and&amp;nbsp;"&lt;FONT color="#339966"&gt;&lt;EM&gt;Longest Period without Ticket&lt;/EM&gt;&lt;/FONT&gt;" : see below screenshot.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;From my understanding, this calculation cannot be done at the dataset level, as it should be dynamically impacted by the filters (for example to limit the scope of data by the tickets' priority, and/or country).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the question is; how, in attached .pbix, we could dynamically create the 2 scorecards I've hardcoded (static texts for now) at the bottom of the chart, and indicate to our users these "&lt;EM&gt;Longest Periods with/without tickets&lt;/EM&gt;"&amp;nbsp;&lt;/P&gt;&lt;P&gt;The objective is to display the start date, the end date and the duration (in days) of the 2 longest periods (with and without ticket)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many many thanks in advance to share your ideas / hints / advices on how to move on this requirement !&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 08:58:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-quot-Longest-Period-quot-to-complete-a-trend-chart/m-p/3494858#M133876</guid>
      <dc:creator>pouletjaune</dc:creator>
      <dc:date>2023-10-25T08:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate "Longest Period" to complete a trend chart with some textual insights</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-quot-Longest-Period-quot-to-complete-a-trend-chart/m-p/3495140#M133891</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not 100% sure if it is seen only by myself, but I see the below when I click the link.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 02:44:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-quot-Longest-Period-quot-to-complete-a-trend-chart/m-p/3495140#M133891</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2023-10-25T02:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate "Longest Period" to complete a trend chart with some textual insights</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-quot-Longest-Period-quot-to-complete-a-trend-chart/m-p/3495507#M133910</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;and thanks for your reply. Can you retry now ? My bad the file was restricted. I've now opened the file to anyone.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 06:50:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-quot-Longest-Period-quot-to-complete-a-trend-chart/m-p/3495507#M133910</guid>
      <dc:creator>pouletjaune</dc:creator>
      <dc:date>2023-10-25T06:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate "Longest Period" to complete a trend chart with some textual insights</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-quot-Longest-Period-quot-to-complete-a-trend-chart/m-p/3497184#M133990</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;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;Longest period with tickets: = 
VAR _condition =
    ADDCOLUMNS (
        ALLSELECTED ( 'Calendar Table'[Calendar Date] ),
        "@condition",
            IF ( [#Tickets] + 0 = 0, 1, 0 )
    )
VAR _partition =
    ADDCOLUMNS (
        _condition,
        "@partition",
            SUMX (
                FILTER (
                    _condition,
                    'Calendar Table'[Calendar Date] &amp;lt;= EARLIER ( 'Calendar Table'[Calendar Date] )
                ),
                [@condition]
            )
    )
VAR _partitioncount =
    GROUPBY ( _partition, [@partition], "@count", SUMX ( CURRENTGROUP (), 1 ) )
VAR _maxpartitioncount =
    MAXX ( _partitioncount, [@count] )
VAR _maxpartitionnumber =
    MAXX ( FILTER ( _partitioncount, [@count] = _maxpartitioncount ), [@partition] )
VAR _period =
    FILTER ( _partition, [@partition] = _maxpartitionnumber )
RETURN
    COUNTROWS ( _period ) - 1 &amp;amp; " days (from "
        &amp;amp; MINX ( _period, 'Calendar Table'[Calendar Date] ) + 1 &amp;amp; " to "
        &amp;amp; MAXX ( _period, 'Calendar Table'[Calendar Date] ) &amp;amp; ")"
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Longest period without tickets: = 
VAR _condition =
    ADDCOLUMNS (
        ALLSELECTED ( 'Calendar Table'[Calendar Date] ),
        "@condition",
            IF ( [#Tickets] + 0 &amp;lt;&amp;gt; 0, 1, 0 )
    )
VAR _partition =
    ADDCOLUMNS (
        _condition,
        "@partition",
            SUMX (
                FILTER (
                    _condition,
                    'Calendar Table'[Calendar Date] &amp;lt;= EARLIER ( 'Calendar Table'[Calendar Date] )
                ),
                [@condition]
            )
    )
VAR _partitioncount =
    GROUPBY ( _partition, [@partition], "@count", SUMX ( CURRENTGROUP (), 1 ) )
VAR _maxpartitioncount =
    MAXX ( _partitioncount, [@count] )
VAR _maxpartitionnumber =
    MAXX ( FILTER ( _partitioncount, [@count] = _maxpartitioncount ), [@partition] )
VAR _period =
    FILTER ( _partition, [@partition] = _maxpartitionnumber )
RETURN
    COUNTROWS ( _period ) - 1 &amp;amp; " days (from "
        &amp;amp; MINX ( _period, 'Calendar Table'[Calendar Date] ) + 1 &amp;amp; " to "
        &amp;amp; MAXX ( _period, 'Calendar Table'[Calendar Date] ) &amp;amp; ")"
&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 25 Oct 2023 18:38:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-quot-Longest-Period-quot-to-complete-a-trend-chart/m-p/3497184#M133990</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2023-10-25T18:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate "Longest Period" to complete a trend chart with some textual insights</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-quot-Longest-Period-quot-to-complete-a-trend-chart/m-p/3497469#M134012</link>
      <description>&lt;P&gt;You rock !!!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt; That is working like a charm ! Can't thank you enough for this. You made my day. And not only this is working perfectly, but looking at your solution and code, I learnt some nice DAX features here&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, thanks a lot &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;Have a nice evening / day.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 22:36:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-quot-Longest-Period-quot-to-complete-a-trend-chart/m-p/3497469#M134012</guid>
      <dc:creator>pouletjaune</dc:creator>
      <dc:date>2023-10-25T22:36:13Z</dc:date>
    </item>
  </channel>
</rss>

