<?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 Help finding issue in measure in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-finding-issue-in-measure/m-p/3684356#M143107</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a table (RISK_EVALUATION) that contains risk evaluations for RISKIDs (can be multiple) along with dates and outcomes. I then created a measure that I intent to include in a matrix to count how many risks have the latest evaluation as "Not Assessed".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The matrix will have the last day of the month from a calendar table as columns.&amp;nbsp; A RISKID should be counted on that month if the latest evaluation, even if done many months ago, had a value of "Not Assessed". It'd look like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Sep-23&lt;/TD&gt;&lt;TD&gt;Oct-23&lt;/TD&gt;&lt;TD&gt;Nov-23&lt;/TD&gt;&lt;TD&gt;Dec-23&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;# Risks Not Assessed&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;# Risks Not Assessed =&lt;/EM&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;EM&gt;var _selectdate = MAX(dCalendar[Date])&lt;/EM&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;EM&gt;var tmp = &amp;nbsp;FILTER( ALL( RISK_EVALUATION), RISK_EVALUATION[RE_DATE] &amp;lt;= _selectdate) --create a temp table with evaluations only up to the date selected&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;var tmp1 = SUMMARIZE(tmp, [RISKID], "Max Date", MAXX( RISK_EVALUATION, RISK_EVALUATION[RE_DATE])) --create a temp table summarising risk by the latest evaluation date&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;var tmp2 = SELECTCOLUMNS( ADDCOLUMNS( tmp1, "Concate_Str", [RISKID] &amp;amp; [Max Date]), "Concate_Str", [Concate_Str]) --create a temp table with single column concatenating riskid and mre date&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;var tmp3 = FILTER( tmp, [RISKID] &amp;amp; [MRE_DATE] IN tmp2) --create temp table based on first tmp, filtering only those with the latest RE date for each risk&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;var tmp4 = CALCULATETABLE( VALUES( RISK_EVALUATION[RISKID]), FILTER( tmp3, [RE_RATING] = "Not Assessed" )) --create temp table for the risks where the latest RE is defined as not assessed.&amp;nbsp;&lt;/EM&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;EM&gt;var _a = COUNTROWS(tmp4) + 0&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;var _risknotassessed = IF( ISBLANK(_a), 0, _a)&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;return&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;_risknotassessed&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This however is not giving me the correct output. More specifically, when I apply some filters, the value of the measure is not impacted by the filters when it should.&amp;nbsp; I've looked at it enough and can't seem to find the issue so hoping the community could help me spot my mistake. Thanks!&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 07 Feb 2024 01:50:36 GMT</pubDate>
    <dc:creator>kamiluc</dc:creator>
    <dc:date>2024-02-07T01:50:36Z</dc:date>
    <item>
      <title>Help finding issue in measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-finding-issue-in-measure/m-p/3684356#M143107</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a table (RISK_EVALUATION) that contains risk evaluations for RISKIDs (can be multiple) along with dates and outcomes. I then created a measure that I intent to include in a matrix to count how many risks have the latest evaluation as "Not Assessed".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The matrix will have the last day of the month from a calendar table as columns.&amp;nbsp; A RISKID should be counted on that month if the latest evaluation, even if done many months ago, had a value of "Not Assessed". It'd look like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Sep-23&lt;/TD&gt;&lt;TD&gt;Oct-23&lt;/TD&gt;&lt;TD&gt;Nov-23&lt;/TD&gt;&lt;TD&gt;Dec-23&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;# Risks Not Assessed&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;# Risks Not Assessed =&lt;/EM&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;EM&gt;var _selectdate = MAX(dCalendar[Date])&lt;/EM&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;EM&gt;var tmp = &amp;nbsp;FILTER( ALL( RISK_EVALUATION), RISK_EVALUATION[RE_DATE] &amp;lt;= _selectdate) --create a temp table with evaluations only up to the date selected&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;var tmp1 = SUMMARIZE(tmp, [RISKID], "Max Date", MAXX( RISK_EVALUATION, RISK_EVALUATION[RE_DATE])) --create a temp table summarising risk by the latest evaluation date&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;var tmp2 = SELECTCOLUMNS( ADDCOLUMNS( tmp1, "Concate_Str", [RISKID] &amp;amp; [Max Date]), "Concate_Str", [Concate_Str]) --create a temp table with single column concatenating riskid and mre date&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;var tmp3 = FILTER( tmp, [RISKID] &amp;amp; [MRE_DATE] IN tmp2) --create temp table based on first tmp, filtering only those with the latest RE date for each risk&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;var tmp4 = CALCULATETABLE( VALUES( RISK_EVALUATION[RISKID]), FILTER( tmp3, [RE_RATING] = "Not Assessed" )) --create temp table for the risks where the latest RE is defined as not assessed.&amp;nbsp;&lt;/EM&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;EM&gt;var _a = COUNTROWS(tmp4) + 0&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;var _risknotassessed = IF( ISBLANK(_a), 0, _a)&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;return&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;_risknotassessed&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This however is not giving me the correct output. More specifically, when I apply some filters, the value of the measure is not impacted by the filters when it should.&amp;nbsp; I've looked at it enough and can't seem to find the issue so hoping the community could help me spot my mistake. Thanks!&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 07 Feb 2024 01:50:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-finding-issue-in-measure/m-p/3684356#M143107</guid>
      <dc:creator>kamiluc</dc:creator>
      <dc:date>2024-02-07T01:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Help finding issue in measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-finding-issue-in-measure/m-p/3684568#M143113</link>
      <description>&lt;P&gt;I have figure it out. My error was on the variable tmp1 which was producing a table with the latest date for all RISKIDs, rather than the latest for each RISKID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've replaced that variable by the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;var tmp1 =&amp;nbsp;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;SUMMARIZE(&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;FILTER(&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;FILTER(RISK_EVALUATION,RISK_EVALUATION[RE_DATE]&amp;lt;=_selectdate),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;RISK_EVALUATION[RE_DATE]&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;= CALCULATE (&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;MAX ( RISK_EVALUATION[RE_DATE] ),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;ALLEXCEPT ( RISK_EVALUATION, RISK_EVALUATION[RISKID] )&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;),[RISKID],[RE_DATE])&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This actually eliminates the need for the variable tmp as well.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2024 04:02:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-finding-issue-in-measure/m-p/3684568#M143113</guid>
      <dc:creator>kamiluc</dc:creator>
      <dc:date>2024-02-07T04:02:01Z</dc:date>
    </item>
  </channel>
</rss>

