<?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: I want the slicer to show current year and one year before in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-want-the-slicer-to-show-current-year-and-one-year-before/m-p/4376138#M173745</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="880413" data-lia-user-login="Bertje123456" class="lia-mention lia-mention-user"&gt;Bertje123456&lt;/a&gt;&amp;nbsp;you can create a calculated column with this code:&lt;/P&gt;
&lt;P&gt;YearLabel = &lt;BR /&gt;IF(&lt;BR /&gt;'Table'[Year] = YEAR(TODAY()),&lt;BR /&gt;"This Year",&lt;BR /&gt;FORMAT('Table'[Year], "YYYY")&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can sort this new column by your year column and use it. If you leave it on "This Year," it will default to the current year and show the other years in the filter menu. If you want to show only This Year and the previous year, modify the code with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;YearLabel =&lt;BR /&gt;VAR THISYEARRR = IF(&lt;BR /&gt;'Table'[Year] = YEAR(TODAY()),&lt;BR /&gt;"This Year",&lt;BR /&gt;FORMAT('Table'[Year], "YYYY")&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;RETURN IF('Table'[Year] = YEAR(TODAY()) || 'Table'[Year] = YEAR(TODAY()) -1, THISYEARRR, BLANK())&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's ok, please accept my answer as solution!&lt;/P&gt;
&lt;P&gt;BBF&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jan 2025 16:40:22 GMT</pubDate>
    <dc:creator>BeaBF</dc:creator>
    <dc:date>2025-01-22T16:40:22Z</dc:date>
    <item>
      <title>I want the slicer to show current year and one year before</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-want-the-slicer-to-show-current-year-and-one-year-before/m-p/4376059#M173741</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having trouble getting a slicer that shows the current year and the option to select last year. So, now we live in 2025. I want it to default to 2025 and the option to choose to see data from year 2024 in the slicer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have applied a hierarchy in the slicer that consists of year and month.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, my data consists of years from 1970 to 2030.&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;P&gt;How can I best do this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 15:46:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-want-the-slicer-to-show-current-year-and-one-year-before/m-p/4376059#M173741</guid>
      <dc:creator>Bertje123456</dc:creator>
      <dc:date>2025-01-22T15:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: I want the slicer to show current year and one year before</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-want-the-slicer-to-show-current-year-and-one-year-before/m-p/4376138#M173745</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="880413" data-lia-user-login="Bertje123456" class="lia-mention lia-mention-user"&gt;Bertje123456&lt;/a&gt;&amp;nbsp;you can create a calculated column with this code:&lt;/P&gt;
&lt;P&gt;YearLabel = &lt;BR /&gt;IF(&lt;BR /&gt;'Table'[Year] = YEAR(TODAY()),&lt;BR /&gt;"This Year",&lt;BR /&gt;FORMAT('Table'[Year], "YYYY")&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can sort this new column by your year column and use it. If you leave it on "This Year," it will default to the current year and show the other years in the filter menu. If you want to show only This Year and the previous year, modify the code with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;YearLabel =&lt;BR /&gt;VAR THISYEARRR = IF(&lt;BR /&gt;'Table'[Year] = YEAR(TODAY()),&lt;BR /&gt;"This Year",&lt;BR /&gt;FORMAT('Table'[Year], "YYYY")&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;RETURN IF('Table'[Year] = YEAR(TODAY()) || 'Table'[Year] = YEAR(TODAY()) -1, THISYEARRR, BLANK())&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's ok, please accept my answer as solution!&lt;/P&gt;
&lt;P&gt;BBF&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 16:40:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-want-the-slicer-to-show-current-year-and-one-year-before/m-p/4376138#M173745</guid>
      <dc:creator>BeaBF</dc:creator>
      <dc:date>2025-01-22T16:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: I want the slicer to show current year and one year before</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-want-the-slicer-to-show-current-year-and-one-year-before/m-p/4376178#M173747</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="880413" data-lia-user-login="Bertje123456" class="lia-mention lia-mention-user"&gt;Bertje123456&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;First, use the following expression to create a table with a year slicer&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then I created a measure using the following expression&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Cure and prev year = 
var currentyear_ = SELECTEDVALUE(year_slicer[Year])
RETURN
IF(SELECTEDVALUE('Calendar 2'[DateKey].[Year])&amp;lt;= currentyear_ &amp;amp;&amp;amp; SELECTEDVALUE('Calendar 2'[DateKey].[Year]) &amp;gt;= currentyear_ - 1,1,0) &lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Use this metric in the Filter panel and set it to 1&lt;BR /&gt;and use the table year_slicer to slicer fields&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, then please consider&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 16:52:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/I-want-the-slicer-to-show-current-year-and-one-year-before/m-p/4376178#M173747</guid>
      <dc:creator>vivek31</dc:creator>
      <dc:date>2025-01-22T16:52:25Z</dc:date>
    </item>
  </channel>
</rss>

