<?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: Filter Value based on the MAX Date available and partially ignoring slicer in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Value-based-on-the-MAX-Date-available-and-partially/m-p/2192183#M51270</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="308095" data-lia-user-login="Dom87326" class="lia-mention lia-mention-user"&gt;Dom87326&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your Error means that you compare whole number type column by text type column. According to your statement, I think DimUserAgg[DateKey] is whole number type .&lt;/P&gt;
&lt;P&gt;"VAR _LM =YEAR( _M ) &amp;amp; 12 &amp;amp; 01" in measure from&amp;nbsp;&lt;SPAN&gt;VahidDM will return text. And you compare it with&amp;nbsp;DimUserAgg[DateKey] in filter.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;Measure =
VAR _M =
    MAX( DimDate[Date] )
VAR _LM =
    YEAR( _M ) &amp;amp; 12 &amp;amp; 01
RETURN
    CALCULATE(
        MAX( DimUserAgg[Number of Logins] ),
        FILTER( ALL( DimUserAgg ), DimUserAgg[DateKey] = _LM )
    )&lt;/LI-CODE&gt;
&lt;P&gt;Format Date column to &lt;SPAN&gt;yyyymmdd will return text type result as well.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can try this code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;Measure =
VAR _M =
    MAX( DimDate[Date] )
VAR _LM =
    YEAR( _M )*10000 + 1201
RETURN
    CALCULATE(
        SUM( DimUserAgg[Number of Logins] ),
        FILTER( ALL( DimUserAgg ), DimUserAgg[DateKey] = _LM )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Tue, 16 Nov 2021 10:16:03 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-11-16T10:16:03Z</dc:date>
    <item>
      <title>Filter Value based on the MAX Date available and partially ignoring slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Value-based-on-the-MAX-Date-available-and-partially/m-p/2188463#M51105</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dimUserAgg table that defines aggregated user activity data&amp;nbsp;(number of logins and etc.) accumulated per month:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;dimDate 1:* dimUserAgg (relationship not active)&lt;BR /&gt;dimDate 1:* Fact (active relationship)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to filter on the &lt;STRONG&gt;max Number of Logins&lt;/STRONG&gt; available based on &lt;STRONG&gt;Date&amp;nbsp;&lt;/STRONG&gt;filters.&amp;nbsp;&lt;STRONG&gt;Max Number of Logins&lt;/STRONG&gt;&amp;nbsp;is always the last month of the year. If date is set to 2020 March,&amp;nbsp;I only want to return the Number of Logins for 2020 Dec, if it's 2021 May then 2021 Dec.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to write a DAX using the Calculate, MAX date function or any other syntax to arrive to this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Thanks in advance for any ideas.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;dimDate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;img /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;dimUserAgg &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;img /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Nov 2021 14:40:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Value-based-on-the-MAX-Date-available-and-partially/m-p/2188463#M51105</guid>
      <dc:creator>Dom87326</dc:creator>
      <dc:date>2021-11-13T14:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: Filter Value based on the MAX Date available and partially ignoring slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Value-based-on-the-MAX-Date-available-and-partially/m-p/2188601#M51109</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="308095" data-lia-user-login="Dom87326" class="lia-mention lia-mention-user"&gt;Dom87326&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Measure =
VAR _M =
    MAX( DimDate[Date] )
VAR _LM =
    YEAR( _M ) &amp;amp; 12 &amp;amp; 01
RETURN
    CALCULATE(
        MAX( DimUserAgg[Number of Logins] ),
        FILTER( ALL( DimUserAgg ), DimUserAgg[DateKey] = _LM )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;helps&lt;/SPAN&gt;&lt;/STRONG&gt;, please consider&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;accepting&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;it as the solution&lt;/SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;to help the other members find it more quickly.&lt;BR /&gt;&lt;STRONG&gt;&lt;SPAN&gt;Appreciate your Kudos!!&lt;BR /&gt;&lt;STRONG&gt;LinkedIn:&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;A href="https://www.linkedin.com/in/vahid-dm/" target="_blank"&gt;www.linkedin.com/in/vahid-dm/&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Nov 2021 00:03:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Value-based-on-the-MAX-Date-available-and-partially/m-p/2188601#M51109</guid>
      <dc:creator>VahidDM</dc:creator>
      <dc:date>2021-11-14T00:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: Filter Value based on the MAX Date available and partially ignoring slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Value-based-on-the-MAX-Date-available-and-partially/m-p/2188968#M51129</link>
      <description>&lt;P&gt;Hello &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="315278" data-lia-user-login="VahidDM" class="lia-mention lia-mention-user"&gt;VahidDM&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've added one more variable for Month.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However with this syntax I get the following error: MdxScript(Model) (358, 57) Calculation error in measure : DAX comparison operations do not support comparing values of type Number with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.&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;test_1 =
VAR _Y =
MAX( DimDate[Date] )
VAR _M =
MAX( DimDate[Date] )
VAR _LM =
YEAR( _Y ) &amp;amp; MONTH( _M ) &amp;amp; VALUE(01)
RETURN
CALCULATE(
MAX( DimUserAgg[Number of Logins] ),
FILTER( ALL( DimUserAgg ), DimUserAgg[%DATE_KEY] = _LM ))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've created DimDate by using below code, while DimUserAgg[%DATE_KEY] is integer type from source.&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;Date =
VAR MinYear = YEAR ( MIN ( 'Fact'[%DATE] ) )
VAR MaxYear = YEAR ( MAX ( 'Fact'[%DATE] ) )
RETURN
ADDCOLUMNS (
FILTER (
CALENDARAUTO ( ),
YEAR ( [Date] ) &amp;gt;= MinYear &amp;amp;&amp;amp;
YEAR ( [Date] ) &amp;lt;= MaxYear
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible using FORMAT to change DimUserAgg[%DATE_KEY] type to date yyyymmdd?&lt;/P&gt;</description>
      <pubDate>Sun, 14 Nov 2021 19:46:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Value-based-on-the-MAX-Date-available-and-partially/m-p/2188968#M51129</guid>
      <dc:creator>Dom87326</dc:creator>
      <dc:date>2021-11-14T19:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: Filter Value based on the MAX Date available and partially ignoring slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Value-based-on-the-MAX-Date-available-and-partially/m-p/2192183#M51270</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="308095" data-lia-user-login="Dom87326" class="lia-mention lia-mention-user"&gt;Dom87326&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your Error means that you compare whole number type column by text type column. According to your statement, I think DimUserAgg[DateKey] is whole number type .&lt;/P&gt;
&lt;P&gt;"VAR _LM =YEAR( _M ) &amp;amp; 12 &amp;amp; 01" in measure from&amp;nbsp;&lt;SPAN&gt;VahidDM will return text. And you compare it with&amp;nbsp;DimUserAgg[DateKey] in filter.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;Measure =
VAR _M =
    MAX( DimDate[Date] )
VAR _LM =
    YEAR( _M ) &amp;amp; 12 &amp;amp; 01
RETURN
    CALCULATE(
        MAX( DimUserAgg[Number of Logins] ),
        FILTER( ALL( DimUserAgg ), DimUserAgg[DateKey] = _LM )
    )&lt;/LI-CODE&gt;
&lt;P&gt;Format Date column to &lt;SPAN&gt;yyyymmdd will return text type result as well.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can try this code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;Measure =
VAR _M =
    MAX( DimDate[Date] )
VAR _LM =
    YEAR( _M )*10000 + 1201
RETURN
    CALCULATE(
        SUM( DimUserAgg[Number of Logins] ),
        FILTER( ALL( DimUserAgg ), DimUserAgg[DateKey] = _LM )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 10:16:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Filter-Value-based-on-the-MAX-Date-available-and-partially/m-p/2192183#M51270</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-11-16T10:16:03Z</dc:date>
    </item>
  </channel>
</rss>

