<?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: Dynamic measure flag not working on every row in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-measure-flag-not-working-on-every-row/m-p/4172471#M165714</link>
    <description>&lt;P&gt;Hi Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Based on the description, check if any filters are applied. Using the following DAX formula.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Window Flag = 
VAR SurvYear = SELECTEDVALUE('My Hospital Summary'[Survey Year])
var _defyear = SELECTEDVALUE('Def Peer Group Summary'[Survey Year])
VAR flag =
calculate(
    countrows('Def Peer Group Summary'),filter('Def Peer Group Summary', 'Def Peer Group Summary'[Survey Year] &amp;lt;= SurvYear &amp;amp;&amp;amp; 'Def Peer Group Summary'[Survey Year] &amp;gt;= SurvYear-2))
Return flag

// RETURN
//         IF(
//             _defyear &amp;lt;= SurvYear &amp;amp;&amp;amp;
//             _defyear &amp;gt;= SurvYear - 2,
//             1,  -- Return 1 for True
//             0   -- Return 0 for False
//         )
&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;Best Regards,&lt;/P&gt;
&lt;P&gt;Wisdom Wu&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Sep 2024 07:55:39 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-09-30T07:55:39Z</dc:date>
    <item>
      <title>Dynamic measure flag not working on every row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-measure-flag-not-working-on-every-row/m-p/4170685#M165671</link>
      <description>&lt;P&gt;I'm attempting to use DAX code that will flag survey years within a window of time. The window is equal to a selected year and 2 years before. The selected year will change based on the ID that is selected so I'm trying to use a measure over a column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current DAX attempt is:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Window Flag = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; SurvYear = &lt;/SPAN&gt;&lt;SPAN&gt;selectedvalue&lt;/SPAN&gt;&lt;SPAN&gt;('My Hospital Summary'[Survey Year])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; flag = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;calculate&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;countrows&lt;/SPAN&gt;&lt;SPAN&gt;('Def Peer Group Summary'),&lt;/SPAN&gt;&lt;SPAN&gt;filter&lt;/SPAN&gt;&lt;SPAN&gt;('Def Peer Group Summary', 'Def Peer Group Summary'[Survey Year] &amp;lt;= SurvYear &amp;amp;&amp;amp; 'Def Peer Group Summary'[Survey Year] &amp;gt;= SurvYear-&lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Return&lt;/SPAN&gt;&lt;SPAN&gt; flag&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;My current result is: &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's almost doing exactly what I need but for some reason it is not counting the rows of all the IDs. Ideally in the above screenshot there should be a 1 next to every year that is 2021-2023.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be great appreciated!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 24 Sep 2024 13:25:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-measure-flag-not-working-on-every-row/m-p/4170685#M165671</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-24T13:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic measure flag not working on every row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-measure-flag-not-working-on-every-row/m-p/4171047#M165682</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The key here is using the ALL('Def Peer Group Summary') to remove the filter on any other columns that might be limiting the results to a specific ID. This should ensure that all years between 2021 and 2023 are flagged with a 1, regardless of the selected ID.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Window Flag =
VAR SurvYear = SELECTEDVALUE('My Hospital Summary'[Survey Year])
RETURN
    CALCULATE(
        IF(
            'Def Peer Group Summary'[Survey Year] &amp;lt;= SurvYear &amp;amp;&amp;amp;
            'Def Peer Group Summary'[Survey Year] &amp;gt;= SurvYear - 2,
            1,  -- Return 1 for True
            0   -- Return 0 for False
        ),
        ALL('Def Peer Group Summary') -- Ignores filter context on the table for ID
    )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2024 15:05:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-measure-flag-not-working-on-every-row/m-p/4171047#M165682</guid>
      <dc:creator>DataNinja777</dc:creator>
      <dc:date>2024-09-24T15:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic measure flag not working on every row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-measure-flag-not-working-on-every-row/m-p/4171157#M165692</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="608865" data-lia-user-login="DataNinja777" class="lia-mention lia-mention-user"&gt;DataNinja777&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for telling me about the all function. However, when I try to use apply this, I get an error about 'Def Peer Group Summary'[Survey Year]. The error says it is not able to determine a single value. The Survey Year is not currently in a date table or anything like that to be unique values. Does it need to be to make use of this code?&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>Tue, 24 Sep 2024 15:36:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-measure-flag-not-working-on-every-row/m-p/4171157#M165692</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-24T15:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic measure flag not working on every row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-measure-flag-not-working-on-every-row/m-p/4172471#M165714</link>
      <description>&lt;P&gt;Hi Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Based on the description, check if any filters are applied. Using the following DAX formula.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Window Flag = 
VAR SurvYear = SELECTEDVALUE('My Hospital Summary'[Survey Year])
var _defyear = SELECTEDVALUE('Def Peer Group Summary'[Survey Year])
VAR flag =
calculate(
    countrows('Def Peer Group Summary'),filter('Def Peer Group Summary', 'Def Peer Group Summary'[Survey Year] &amp;lt;= SurvYear &amp;amp;&amp;amp; 'Def Peer Group Summary'[Survey Year] &amp;gt;= SurvYear-2))
Return flag

// RETURN
//         IF(
//             _defyear &amp;lt;= SurvYear &amp;amp;&amp;amp;
//             _defyear &amp;gt;= SurvYear - 2,
//             1,  -- Return 1 for True
//             0   -- Return 0 for False
//         )
&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;Best Regards,&lt;/P&gt;
&lt;P&gt;Wisdom Wu&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2024 07:55:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-measure-flag-not-working-on-every-row/m-p/4172471#M165714</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-30T07:55:39Z</dc:date>
    </item>
  </channel>
</rss>

