<?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 Remove Variable filter context in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Remove-Variable-filter-context/m-p/2594532#M74841</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am calculating earned premium up till a specific date using the variable "LatestReportingDate".&lt;BR /&gt;However, when using this variable, the filter context "YOA &amp;lt;= 2020" is kept.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Earned =&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR LatestReportingDate =&amp;nbsp;&lt;/P&gt;&lt;P&gt;CALCULATE(MAX(TABLE[ReportingPeriodStartDate]),&lt;BR /&gt;FILTER(TABLE, TABLE[YOA] &amp;lt;= 2020))&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;RETURN CALCULATE(SUM(TABLE[EarnedPremium]),&lt;BR /&gt;FILTER(TABLE, TABLE[ReportingPeriodStartDate] = LatestReportingDate)&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;When visualizing&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Class&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;YOA&lt;/TD&gt;&lt;TD&gt;Earned&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Earned&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;xxx&lt;/TD&gt;&lt;TD&gt;xxx&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;xxx&lt;/TD&gt;&lt;TD&gt;xxx&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021&lt;/TD&gt;&lt;TD&gt;BLANK&lt;/TD&gt;&lt;TD&gt;BLANK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2022&lt;/TD&gt;&lt;TD&gt;BLANK&lt;/TD&gt;&lt;TD&gt;BLANK&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;It seems the filter context from LatestReportingPeriod spills over such that earned is not calculated for 2021 and 2022 YOA.&amp;nbsp;&lt;BR /&gt;I have tried using ALL, ALLEXCEPT to no avail. This also removes connections in the model, which I do not want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jun 2022 09:56:19 GMT</pubDate>
    <dc:creator>MrMichael</dc:creator>
    <dc:date>2022-06-22T09:56:19Z</dc:date>
    <item>
      <title>Remove Variable filter context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Remove-Variable-filter-context/m-p/2594532#M74841</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am calculating earned premium up till a specific date using the variable "LatestReportingDate".&lt;BR /&gt;However, when using this variable, the filter context "YOA &amp;lt;= 2020" is kept.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Earned =&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR LatestReportingDate =&amp;nbsp;&lt;/P&gt;&lt;P&gt;CALCULATE(MAX(TABLE[ReportingPeriodStartDate]),&lt;BR /&gt;FILTER(TABLE, TABLE[YOA] &amp;lt;= 2020))&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;RETURN CALCULATE(SUM(TABLE[EarnedPremium]),&lt;BR /&gt;FILTER(TABLE, TABLE[ReportingPeriodStartDate] = LatestReportingDate)&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;When visualizing&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Class&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;YOA&lt;/TD&gt;&lt;TD&gt;Earned&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Earned&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;xxx&lt;/TD&gt;&lt;TD&gt;xxx&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;xxx&lt;/TD&gt;&lt;TD&gt;xxx&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2021&lt;/TD&gt;&lt;TD&gt;BLANK&lt;/TD&gt;&lt;TD&gt;BLANK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2022&lt;/TD&gt;&lt;TD&gt;BLANK&lt;/TD&gt;&lt;TD&gt;BLANK&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;It seems the filter context from LatestReportingPeriod spills over such that earned is not calculated for 2021 and 2022 YOA.&amp;nbsp;&lt;BR /&gt;I have tried using ALL, ALLEXCEPT to no avail. This also removes connections in the model, which I do not want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 09:56:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Remove-Variable-filter-context/m-p/2594532#M74841</guid>
      <dc:creator>MrMichael</dc:creator>
      <dc:date>2022-06-22T09:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Variable filter context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Remove-Variable-filter-context/m-p/2594693#M74844</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="319498" data-lia-user-login="MrMichael" class="lia-mention lia-mention-user"&gt;MrMichael&lt;/a&gt;&amp;nbsp;try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Earned =
VAR LatestReportingDate =
    CALCULATE (
        MAX ( TABLE[ReportingPeriodStartDate] ),
        TABLE[YOA] &amp;lt;= 2020
    )
RETURN
    CALCULATE (
        SUM ( TABLE[EarnedPremium] ),
        TABLE[ReportingPeriodStartDate] = LatestReportingDate
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;A href="https://www.spartabi.com" target="_blank" rel="noopener"&gt;&lt;img /&gt;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://www.spartabi.com" target="_blank" rel="noopener"&gt;&lt;img /&gt;&lt;/A&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;A href="https://www.linkedin.com/company/spartabi" target="_blank" rel="noopener"&gt;&lt;img /&gt;&lt;/A&gt; &amp;nbsp;&amp;nbsp;&lt;A href="https://www.facebook.com/SpartaBI" target="_blank" rel="noopener"&gt;&lt;img /&gt;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Data-Stories-Gallery/Contoso-by-SpartaBI/m-p/2449543" target="_blank" rel="noopener"&gt;&lt;FONT size="4" color="#0000EE"&gt;Showcase Report – Contoso By SpartaBI&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 11:01:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Remove-Variable-filter-context/m-p/2594693#M74844</guid>
      <dc:creator>SpartaBI</dc:creator>
      <dc:date>2022-06-22T11:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Variable filter context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Remove-Variable-filter-context/m-p/2594710#M74846</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="319498" data-lia-user-login="MrMichael" class="lia-mention lia-mention-user"&gt;MrMichael&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;The &lt;SPAN&gt;LatestReportingDate&amp;nbsp;will return the last available date in in current filter context only if the year is 2020 or less. In the case of the year 2021 it will return blank. In this case the measure will also return blank as there is no blank date in your table.&amp;nbsp;&lt;BR /&gt;You can FILTER ( ALL ( Table ), ..... in both measures but the best way to achieve what you need is the have a date table.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 11:07:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Remove-Variable-filter-context/m-p/2594710#M74846</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-06-22T11:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Variable filter context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Remove-Variable-filter-context/m-p/2594775#M74850</link>
      <description>&lt;P&gt;Thank you.&amp;nbsp;&lt;BR /&gt;However, I find that using ALL on both measures, removes connections in my model which makes earned premium the same for all years.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 11:21:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Remove-Variable-filter-context/m-p/2594775#M74850</guid>
      <dc:creator>MrMichael</dc:creator>
      <dc:date>2022-06-22T11:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Variable filter context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Remove-Variable-filter-context/m-p/2594806#M74853</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="319498" data-lia-user-login="MrMichael" class="lia-mention lia-mention-user"&gt;MrMichael&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;This is why I advised you to use a date table. This will give you the freedom&amp;nbsp;to filter without the need for sophisticated dax code.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 11:38:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Remove-Variable-filter-context/m-p/2594806#M74853</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-06-22T11:38:39Z</dc:date>
    </item>
  </channel>
</rss>

