<?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: Allselected with filtration in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Allselected-with-filtration/m-p/3321957#M124350</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="484463" data-lia-user-login="Amrselim1989" class="lia-mention lia-mention-user"&gt;Amrselim1989&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I have two options in my mind to solve this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;#1 You could in you measure get the latest date with sales data, derive year and month from this date, and filter your data table for including only months before that current month.&lt;BR /&gt;# 2 You can add a column to your dimDate table that marks current and previous months and then in the measure you can use this column to only include previous months. This is what I'm gonna show you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Add this as a &lt;STRONG&gt;calculated column&lt;/STRONG&gt; to you &lt;STRONG&gt;dimDate&lt;/STRONG&gt; Table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Running Month = DATEDIFF ( TODAY(), 'dimDate'[Date], MONTH )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will give you a column that contains 0 for the current month, -1, -2, -3, ... for past months and 1, 2, 3, ... for future month. Instead of using TODAY() in the code, you can alternatively relate to your last date with sales as today if there is some delay in your data processing pipeline until sales data actually arrives in your report.&lt;BR /&gt;Then wrap you code into a CALCULATE() function that exludes the current (and future) months:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE (

    VAR MaxSales = MAXX ( ALLSELECTED ( dimDate[Year], dimDate[Month], DimDate[MMM] ), [Sum of Net Sales Value] ) 
    VAR MinSales = MINX ( ALLSELECTED ( dimDate[Year], dimDate[Month], dimDate[MMM] ), [Sum of Net Sales Value] ) 
    VAR Result = IF ( [Sum of Net Sales Value] = MaxSales || [Sum of Net Sales Value] = MinSales, 
    [Sum of Net Sales Value],
     " " ) 
    RETURN Result

    ,KEEPFILTERS( 'dimDate'[Running Month] &amp;lt; 0 )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;BR&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;P class="lia-align-right"&gt;&lt;A title="GitHub" href="https://github.com/MartinBubenheimer" target="_blank" rel="noopener"&gt;&lt;img /&gt;&lt;/A&gt;&lt;A title="linkedin" href="https://www.linkedin.com/in/martin-bubenheimer-9ba99271/" target="_blank" rel="noopener"&gt;&lt;img /&gt;&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 09 Jul 2023 15:01:39 GMT</pubDate>
    <dc:creator>Martin_D</dc:creator>
    <dc:date>2023-07-09T15:01:39Z</dc:date>
    <item>
      <title>Allselected with filtration</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Allselected-with-filtration/m-p/3321887#M124344</link>
      <description>&lt;P&gt;hello Guys,&lt;/P&gt;&lt;P&gt;i hope you can help me with this,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have this code&lt;/P&gt;&lt;PRE&gt;&lt;FONT&gt;&lt;FONT&gt;VAR&lt;/FONT&gt;&lt;FONT&gt; MaxSales = &lt;/FONT&gt;&lt;FONT&gt;MAXX&lt;/FONT&gt; &lt;FONT&gt;(&lt;/FONT&gt; &lt;FONT&gt;ALLSELECTED&lt;/FONT&gt; &lt;FONT&gt;(&lt;/FONT&gt;&lt;FONT&gt; dimDate[Year], dimDate[Month], DimDate[MMM] &lt;/FONT&gt;&lt;FONT&gt;)&lt;/FONT&gt;&lt;FONT&gt;, [Sum of Net Sales Value] &lt;/FONT&gt;&lt;FONT&gt;)&lt;/FONT&gt;&lt;FONT&gt; &lt;BR /&gt;VAR&lt;/FONT&gt;&lt;FONT&gt; MinSales = &lt;/FONT&gt;&lt;FONT&gt;MINX&lt;/FONT&gt; &lt;FONT&gt;(&lt;/FONT&gt; &lt;FONT&gt;ALLSELECTED&lt;/FONT&gt; &lt;FONT&gt;(&lt;/FONT&gt;&lt;FONT&gt; dimDate[Year], dimDate[Month], dimDate[MMM] &lt;/FONT&gt;&lt;FONT&gt;)&lt;/FONT&gt;&lt;FONT&gt;, [Sum of Net Sales Value] &lt;/FONT&gt;&lt;FONT&gt;)&lt;/FONT&gt;&lt;FONT&gt; &lt;BR /&gt;VAR&lt;/FONT&gt;&lt;FONT&gt; Result = &lt;/FONT&gt;&lt;FONT&gt;IF&lt;/FONT&gt; &lt;FONT&gt;(&lt;/FONT&gt;&lt;FONT&gt; [Sum of Net Sales Value] = MaxSales || [Sum of Net Sales Value] = MinSales, &lt;BR /&gt;[Sum of Net Sales Value],&lt;BR /&gt; &lt;/FONT&gt;&lt;FONT&gt;" "&lt;/FONT&gt; &lt;FONT&gt;)&lt;/FONT&gt;&lt;FONT&gt; &lt;BR /&gt;RETURN&lt;/FONT&gt;&lt;FONT&gt; Result&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;which is working so fine for me, except for one thing, i wish i can filter this code the min and max value doesn't consider the current month's date in it, because it always shows the current month as the Min sales wish is natural cause the month didn't finish yet...&lt;/P&gt;&lt;P&gt;so I wish to remove the month of July 2023 from this code...&lt;/P&gt;&lt;P&gt;Any help, please?!!&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2023 13:06:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Allselected-with-filtration/m-p/3321887#M124344</guid>
      <dc:creator>Amrselim1989</dc:creator>
      <dc:date>2023-07-09T13:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Allselected with filtration</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Allselected-with-filtration/m-p/3321957#M124350</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="484463" data-lia-user-login="Amrselim1989" class="lia-mention lia-mention-user"&gt;Amrselim1989&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I have two options in my mind to solve this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;#1 You could in you measure get the latest date with sales data, derive year and month from this date, and filter your data table for including only months before that current month.&lt;BR /&gt;# 2 You can add a column to your dimDate table that marks current and previous months and then in the measure you can use this column to only include previous months. This is what I'm gonna show you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Add this as a &lt;STRONG&gt;calculated column&lt;/STRONG&gt; to you &lt;STRONG&gt;dimDate&lt;/STRONG&gt; Table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Running Month = DATEDIFF ( TODAY(), 'dimDate'[Date], MONTH )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will give you a column that contains 0 for the current month, -1, -2, -3, ... for past months and 1, 2, 3, ... for future month. Instead of using TODAY() in the code, you can alternatively relate to your last date with sales as today if there is some delay in your data processing pipeline until sales data actually arrives in your report.&lt;BR /&gt;Then wrap you code into a CALCULATE() function that exludes the current (and future) months:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE (

    VAR MaxSales = MAXX ( ALLSELECTED ( dimDate[Year], dimDate[Month], DimDate[MMM] ), [Sum of Net Sales Value] ) 
    VAR MinSales = MINX ( ALLSELECTED ( dimDate[Year], dimDate[Month], dimDate[MMM] ), [Sum of Net Sales Value] ) 
    VAR Result = IF ( [Sum of Net Sales Value] = MaxSales || [Sum of Net Sales Value] = MinSales, 
    [Sum of Net Sales Value],
     " " ) 
    RETURN Result

    ,KEEPFILTERS( 'dimDate'[Running Month] &amp;lt; 0 )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;BR&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;P class="lia-align-right"&gt;&lt;A title="GitHub" href="https://github.com/MartinBubenheimer" target="_blank" rel="noopener"&gt;&lt;img /&gt;&lt;/A&gt;&lt;A title="linkedin" href="https://www.linkedin.com/in/martin-bubenheimer-9ba99271/" target="_blank" rel="noopener"&gt;&lt;img /&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2023 15:01:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Allselected-with-filtration/m-p/3321957#M124350</guid>
      <dc:creator>Martin_D</dc:creator>
      <dc:date>2023-07-09T15:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Allselected with filtration</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Allselected-with-filtration/m-p/3322002#M124360</link>
      <description>&lt;P&gt;Thank you man, you are a genius &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2023 17:07:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Allselected-with-filtration/m-p/3322002#M124360</guid>
      <dc:creator>Amrselim1989</dc:creator>
      <dc:date>2023-07-09T17:07:16Z</dc:date>
    </item>
  </channel>
</rss>

