<?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: YTD filter based on the selected month in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4379040#M173841</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="643826" data-lia-user-login="David83300" class="lia-mention lia-mention-user"&gt;David83300&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest you to create a Monthfilter table as below.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MonthFilter = 
VAR _MonthFilter =
DATATABLE(
    "MonthFilter",STRING,
    "Order",INTEGER,
    {
        {"MTD",1},
        {"YTD",2},
        {"Full Year",3}
        }
)
Return
_MonthFilter&lt;/LI-CODE&gt;
&lt;P&gt;Then create a measure to filter your visual in visual level filter and set it to show items when value = 1.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
SWITCH(
    MAX(MonthFilter[Order]),
    1,IF(MAX(DIM_DATE[MONTH]) = SELECTEDVALUE(SelectedMonth[SelectedMonth]),1,0),
    2,IF(MAX(DIM_DATE[MONTH]) &amp;lt;= SELECTEDVALUE(SelectedMonth[SelectedMonth]),1,0),
    3,1)&lt;/LI-CODE&gt;
&lt;P&gt;Result is as below.&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;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>Fri, 24 Jan 2025 06:06:49 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2025-01-24T06:06:49Z</dc:date>
    <item>
      <title>YTD filter based on the selected month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4377852#M173810</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a dynamic time filter based on the selected month (Always one month selected in the report):&lt;/P&gt;&lt;P&gt;MTD: Selected month&lt;/P&gt;&lt;P&gt;YTD: Janv - to selected month (No cumulation !)&lt;/P&gt;&lt;P&gt;FY: Janv - Dec&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First I tried with calculation group but I always get cumulated YTD result. Now I try with a DAX table but I can't link the selected month in the DAX table...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Model:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DAX Filter table:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;MonthFilter = 
Var _SelectedMonth= max(SelectedMonth[SelectedMonth])

Var _MonthFilter = UNION(

ADDCOLUMNS(
    SELECTCOLUMNS(GENERATESERIES ( _SelectedMonth,_SelectedMonth,1 ) ,"Mois",INT([Value]))
,"MonthFilter","MTD"
,"Order",1)

,ADDCOLUMNS(
    SELECTCOLUMNS(GENERATESERIES ( 1,_SelectedMonth,1 ) ,"Mois",INT([Value]))
,"MonthFilter","YTD"
,"Order",2)


,ADDCOLUMNS(
    SELECTCOLUMNS(GENERATESERIES ( 1, 12 ,1 ) ,"Mois",INT([Value]))
,"MonthFilter","Full Year"
,"Order",3)
)

Return
_MonthFilter&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2025 13:43:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4377852#M173810</guid>
      <dc:creator>David83300</dc:creator>
      <dc:date>2025-01-23T13:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: YTD filter based on the selected month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4377875#M173812</link>
      <description>&lt;P&gt;Example PBIX file:&lt;/P&gt;&lt;P&gt;&lt;A href="https://we.tl/t-x9zpYv40XQ" target="_blank"&gt;https://we.tl/t-x9zpYv40XQ&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2025 13:54:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4377875#M173812</guid>
      <dc:creator>David83300</dc:creator>
      <dc:date>2025-01-23T13:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: YTD filter based on the selected month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4379040#M173841</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="643826" data-lia-user-login="David83300" class="lia-mention lia-mention-user"&gt;David83300&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest you to create a Monthfilter table as below.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MonthFilter = 
VAR _MonthFilter =
DATATABLE(
    "MonthFilter",STRING,
    "Order",INTEGER,
    {
        {"MTD",1},
        {"YTD",2},
        {"Full Year",3}
        }
)
Return
_MonthFilter&lt;/LI-CODE&gt;
&lt;P&gt;Then create a measure to filter your visual in visual level filter and set it to show items when value = 1.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
SWITCH(
    MAX(MonthFilter[Order]),
    1,IF(MAX(DIM_DATE[MONTH]) = SELECTEDVALUE(SelectedMonth[SelectedMonth]),1,0),
    2,IF(MAX(DIM_DATE[MONTH]) &amp;lt;= SELECTEDVALUE(SelectedMonth[SelectedMonth]),1,0),
    3,1)&lt;/LI-CODE&gt;
&lt;P&gt;Result is as below.&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;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>Fri, 24 Jan 2025 06:06:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4379040#M173841</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-24T06:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: YTD filter based on the selected month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4379734#M173859</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;your solution works. But it's not very practical, I would prefer to avoid adding visual filters everywhere &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; But maybe this is the only way ?&lt;/P&gt;&lt;P&gt;And by the way it's not working anymore if I switch to quarter dimension instead of month&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 12:32:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4379734#M173859</guid>
      <dc:creator>David83300</dc:creator>
      <dc:date>2025-01-24T12:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: YTD filter based on the selected month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4381938#M173950</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="643826" data-lia-user-login="David83300" class="lia-mention lia-mention-user"&gt;David83300&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your requirement requires matrix visual for dynamic display, I suggest you try using measure to get dynamic results or you can try to create custom visuals by yourself.&lt;/P&gt;
&lt;P&gt;If you want to switch to&amp;nbsp;&lt;SPAN&gt;quarter dimension, we can update the measure and the MonthFilter table to achieve your goal.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please show us a screenshot with the result you want switching to quarter dimension.&lt;/SPAN&gt;&lt;/P&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 08:07:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4381938#M173950</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-27T08:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: YTD filter based on the selected month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4386657#M174137</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;, I added a Quarter dimension in the PBIX. As you can see it's not working right now&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;&lt;A href="https://we.tl/t-OeO6cwyLNw" target="_blank"&gt;https://we.tl/t-OeO6cwyLNw&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 16:49:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4386657#M174137</guid>
      <dc:creator>David83300</dc:creator>
      <dc:date>2025-01-29T16:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: YTD filter based on the selected month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4392170#M174358</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="643826" data-lia-user-login="David83300" class="lia-mention lia-mention-user"&gt;David83300&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here I update my sample, you can download and check the attachment.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;If this reply still couldn't help you solve your issue, the transfer has been expired, please share again with us.&lt;/P&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 09:30:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4392170#M174358</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-02-03T09:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: YTD filter based on the selected month</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4392962#M174385</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks but it's only working if I keep the month dimension in the chart.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need something that can work without the month dimension, is that possible ?&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>Mon, 03 Feb 2025 17:45:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/YTD-filter-based-on-the-selected-month/m-p/4392962#M174385</guid>
      <dc:creator>David83300</dc:creator>
      <dc:date>2025-02-03T17:45:02Z</dc:date>
    </item>
  </channel>
</rss>

