<?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 how many months under target in a row in Power BI in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-how-many-months-under-target-in-a-row-in-Power-BI/m-p/4408131#M175038</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.&lt;/P&gt;
&lt;P&gt;Please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;I tried to use the WINDOW DAX function in the measure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/window-function-dax?wt.mc_id=DP-MVP-5004989" target="_blank" rel="noopener"&gt;WINDOW function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&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;&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;diff target vs actual: = 
SUM( sales_fct[target_sales] ) - SUM( sales_fct[actual_sales] )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/window-function-dax?wt.mc_id=DP-MVP-5004989" target="_blank" rel="noopener"&gt;WINDOW function (DAX) - DAX | Microsoft Learn&lt;/A&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;Running months below target: = 
VAR _current =
    MAX ( calendar_dim[Year-Month sort] )
VAR _condition =
    ADDCOLUMNS (
        SUMMARIZE (
            ALL ( sales_fct ),
            calendar_dim[Year-Month],
            calendar_dim[Year-Month sort]
        ),
        "@diff", [diff target vs actual:],
        "@condition",
            INT ( [diff target vs actual:] &amp;lt; 0 ) + 0
    )
VAR _group =
    ADDCOLUMNS (
        _condition,
        "@group",
            INT (
                MAXX (
                    OFFSET ( -1, _condition, ORDERBY ( calendar_dim[Year-Month sort], ASC ) ),
                    [@condition]
                ) = 0
                    || [@condition] = 0
            )
    )
VAR _partition =
    ADDCOLUMNS (
        _group,
        "@partition",
            SUMX (
                WINDOW (
                    1,
                    ABS,
                    0,
                    REL,
                    _group,
                    ORDERBY ( calendar_dim[Year-Month sort], ASC )
                ),
                [@group]
            )
    )
VAR _running =
    ADDCOLUMNS (
        _partition,
        "@running",
            SUMX (
                FILTER (
                    _partition,
                    [@partition] = EARLIER ( [@partition] )
                        &amp;amp;&amp;amp; calendar_dim[Year-Month sort] &amp;lt;= EARLIER ( calendar_dim[Year-Month sort] )
                ),
                [@condition]
            )
    )
RETURN
    IF (
        HASONEVALUE ( calendar_dim[Year-Month] ),
        MAXX (
            FILTER ( _running, calendar_dim[Year-Month sort] = _current ),
            [@running]
        )
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Feb 2025 04:38:34 GMT</pubDate>
    <dc:creator>Jihwan_Kim</dc:creator>
    <dc:date>2025-02-13T04:38:34Z</dc:date>
    <item>
      <title>Calculate how many months under target in a row in Power BI</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-how-many-months-under-target-in-a-row-in-Power-BI/m-p/4407705#M175014</link>
      <description>&lt;P&gt;Hi guys!. I´m brand new with Power BI. I´m trying to figure out how to create a measure that calculates how many months in a row a client has not meet with a target using DAX measures in a visual table, and restart when this client reachs the target. I let you an example of what I'm looking for:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;As you can see, I have a column which indicates the month of the year. I have a measure that indicates the difference between sales and target sales, a measure with 1 if this difference is negative and 0 if is positive. Finally, i´m looking for a measure that bring me a running sum of how many months in a row is under target, and restart the sum when the client gets the target of sales.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have any idea of how can i get this?&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 21:36:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-how-many-months-under-target-in-a-row-in-Power-BI/m-p/4407705#M175014</guid>
      <dc:creator>ARodr3</dc:creator>
      <dc:date>2025-02-12T21:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate how many months under target in a row in Power BI</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-how-many-months-under-target-in-a-row-in-Power-BI/m-p/4408050#M175029</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="930549" data-lia-user-login="ARodr3" class="lia-mention lia-mention-user"&gt;ARodr3&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;You can use new visual calculation function to achieve your need.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Running sum = IF([Out of Target?]&amp;lt;&amp;gt;0,RUNNINGSUM([Out of Target?]),0)&lt;/LI-CODE&gt;
&lt;P style="text-align: justify; text-justify: inter-ideograph;"&gt;&lt;SPAN&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Yang&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Community Support Team&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="text-align: justify; text-justify: inter-ideograph;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="background: white;"&gt;&lt;SPAN&gt;If there is any post &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;helps&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, then please consider &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Accept it as the solution&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;to&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know. &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Thanks a lot!&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="background: white;"&gt;&lt;U&gt;&lt;SPAN&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-Get-Your-Question-Answered-Quickly%2Fba-p%2F38490&amp;amp;data=05%7C01%7Cv-yaningyang%40microsoft.com%7C326a6d727194478c197008dbefc04904%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638367381365912356%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=7IzyI2%2FMOAR%2FYCjWYSKCZL2VPmT4PsxuWBjdUdMWKzo%3D&amp;amp;reserved=0" target="_blank"&gt;How to get your questions answered quickly&lt;/A&gt;&lt;/SPAN&gt;&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;-- &lt;/SPAN&gt;&lt;U&gt;&lt;SPAN&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-provide-sample-data-in-the-Power-BI-Forum%2Fba-p%2F963216&amp;amp;data=05%7C01%7Cv-yaningyang%40microsoft.com%7C326a6d727194478c197008dbefc04904%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638367381365919045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=VeafzdwAsrpisD8s261%2FdyOwJ1aCtBXS3bPA6NODOHY%3D&amp;amp;reserved=0" target="_blank"&gt;&amp;nbsp;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/SPAN&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 03:20:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-how-many-months-under-target-in-a-row-in-Power-BI/m-p/4408050#M175029</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-02-13T03:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate how many months under target in a row in Power BI</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-how-many-months-under-target-in-a-row-in-Power-BI/m-p/4408131#M175038</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.&lt;/P&gt;
&lt;P&gt;Please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;I tried to use the WINDOW DAX function in the measure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/window-function-dax?wt.mc_id=DP-MVP-5004989" target="_blank" rel="noopener"&gt;WINDOW function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&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;&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;diff target vs actual: = 
SUM( sales_fct[target_sales] ) - SUM( sales_fct[actual_sales] )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/window-function-dax?wt.mc_id=DP-MVP-5004989" target="_blank" rel="noopener"&gt;WINDOW function (DAX) - DAX | Microsoft Learn&lt;/A&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;Running months below target: = 
VAR _current =
    MAX ( calendar_dim[Year-Month sort] )
VAR _condition =
    ADDCOLUMNS (
        SUMMARIZE (
            ALL ( sales_fct ),
            calendar_dim[Year-Month],
            calendar_dim[Year-Month sort]
        ),
        "@diff", [diff target vs actual:],
        "@condition",
            INT ( [diff target vs actual:] &amp;lt; 0 ) + 0
    )
VAR _group =
    ADDCOLUMNS (
        _condition,
        "@group",
            INT (
                MAXX (
                    OFFSET ( -1, _condition, ORDERBY ( calendar_dim[Year-Month sort], ASC ) ),
                    [@condition]
                ) = 0
                    || [@condition] = 0
            )
    )
VAR _partition =
    ADDCOLUMNS (
        _group,
        "@partition",
            SUMX (
                WINDOW (
                    1,
                    ABS,
                    0,
                    REL,
                    _group,
                    ORDERBY ( calendar_dim[Year-Month sort], ASC )
                ),
                [@group]
            )
    )
VAR _running =
    ADDCOLUMNS (
        _partition,
        "@running",
            SUMX (
                FILTER (
                    _partition,
                    [@partition] = EARLIER ( [@partition] )
                        &amp;amp;&amp;amp; calendar_dim[Year-Month sort] &amp;lt;= EARLIER ( calendar_dim[Year-Month sort] )
                ),
                [@condition]
            )
    )
RETURN
    IF (
        HASONEVALUE ( calendar_dim[Year-Month] ),
        MAXX (
            FILTER ( _running, calendar_dim[Year-Month sort] = _current ),
            [@running]
        )
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 04:38:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-how-many-months-under-target-in-a-row-in-Power-BI/m-p/4408131#M175038</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2025-02-13T04:38:34Z</dc:date>
    </item>
  </channel>
</rss>

