<?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 Sum of amount of Previous months and remaining months should display zero in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-amount-of-Previous-months-and-remaining-months-should/m-p/3942170#M153261</link>
    <description>&lt;P&gt;&lt;BR /&gt;I have a Year Slicer and a Month Slicer, and I have a Matrix visual.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The requirement is: if I select a Year and Month in the slicers, I need the sum of Amount based on the Category as per the Matrix visual below.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Specifically, I need to show the amount for months less than the selected month.&lt;/P&gt;&lt;P&gt;For example, if I select the month number 5, I need to see the values for months 1, 2, 3, and 4. The remaining months should display zero. In the total row, I need the average of these four months.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The values should be shown for months less than the selected month; the remaining months should display zero.&lt;/P&gt;&lt;P&gt;I don't have a calendar table or anything else; I only have one table which includes both the year and month columns.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;EXPECTED OUT PUT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have uploaded a sample PBIX file for your reference.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I really need your help.&lt;BR /&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/c/31a418f7594bd898/Efnn7xCGYqdGmuFVFvzMqgsBkBMlyt3liy_Cf9oy5JQDFA?e=c7Eunr" target="_blank" rel="noopener"&gt;DVT Report.pbix&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 23 May 2024 07:45:40 GMT</pubDate>
    <dc:creator>Learner27</dc:creator>
    <dc:date>2024-05-23T07:45:40Z</dc:date>
    <item>
      <title>Sum of amount of Previous months and remaining months should display zero</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-amount-of-Previous-months-and-remaining-months-should/m-p/3942170#M153261</link>
      <description>&lt;P&gt;&lt;BR /&gt;I have a Year Slicer and a Month Slicer, and I have a Matrix visual.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The requirement is: if I select a Year and Month in the slicers, I need the sum of Amount based on the Category as per the Matrix visual below.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Specifically, I need to show the amount for months less than the selected month.&lt;/P&gt;&lt;P&gt;For example, if I select the month number 5, I need to see the values for months 1, 2, 3, and 4. The remaining months should display zero. In the total row, I need the average of these four months.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The values should be shown for months less than the selected month; the remaining months should display zero.&lt;/P&gt;&lt;P&gt;I don't have a calendar table or anything else; I only have one table which includes both the year and month columns.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;EXPECTED OUT PUT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have uploaded a sample PBIX file for your reference.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I really need your help.&lt;BR /&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/c/31a418f7594bd898/Efnn7xCGYqdGmuFVFvzMqgsBkBMlyt3liy_Cf9oy5JQDFA?e=c7Eunr" target="_blank" rel="noopener"&gt;DVT Report.pbix&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 07:45:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-amount-of-Previous-months-and-remaining-months-should/m-p/3942170#M153261</guid>
      <dc:creator>Learner27</dc:creator>
      <dc:date>2024-05-23T07:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of amount of Previous months and remaining months should display zero</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-amount-of-Previous-months-and-remaining-months-should/m-p/3943388#M153278</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="583663" data-lia-user-login="Learner27" class="lia-mention lia-mention-user"&gt;Learner27&lt;/a&gt;&amp;nbsp;- This is quite complex with one table, so I have added a disconnected table that takes just the month and year columns. This is created by selecting Modeling &amp;gt;&amp;gt; New Table, you can then add the code below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Date = DISTINCT(SELECTCOLUMNS( 'CVT table', "month", 'CVT table'[Month], "year", 'CVT table'[Year] ))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You then need to change the slicers to use the columns from the new table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After this you can create the following measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR selected_month =
    SELECTEDVALUE ( 'Date'[month] )
VAR selected_year =
    SELECTEDVALUE ( 'Date'[year] )
VAR calc =
    0
        + CALCULATE (
            SUM ( 'CVT table'[Amount] ),
            KEEPFILTERS ( 'CVT table'[Month] &amp;lt; selected_month
                &amp;amp;&amp;amp; 'CVT table'[Year] = selected_year )
        )
VAR max_month_with_amount =
    CALCULATE (
        MAX ( 'CVT table'[Month] ),
        'CVT table'[Amount] &amp;gt; 0,
        'CVT table'[Month] &amp;lt; selected_month
            &amp;amp;&amp;amp; 'CVT table'[Year] = selected_year
    )
RETURN
    IF (
        ISINSCOPE ( 'CVT table'[Month] ),
        calc,
        DIVIDE ( calc, max_month_with_amount, 0 )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will see from the screenshot below this gives you the result you require. There are some missing 0's but this is because there are no values in your table for these months e.g. Adiministration, 2024, 6 - You could solve this by adding blank amount rows in your source table.&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;If this solution works for you, please mark as the solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 10:53:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-amount-of-Previous-months-and-remaining-months-should/m-p/3943388#M153278</guid>
      <dc:creator>mark_endicott</dc:creator>
      <dc:date>2024-05-23T10:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of amount of Previous months and remaining months should display zero</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-amount-of-Previous-months-and-remaining-months-should/m-p/3943431#M153281</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="343036" data-lia-user-login="mark_endicott" class="lia-mention lia-mention-user"&gt;mark_endicott&lt;/a&gt;&amp;nbsp;, Wonder full thankyou so much it is exactly satisfying my requirement I really aperciate you. thank you very much.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 11:13:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Sum-of-amount-of-Previous-months-and-remaining-months-should/m-p/3943431#M153281</guid>
      <dc:creator>Learner27</dc:creator>
      <dc:date>2024-05-23T11:13:58Z</dc:date>
    </item>
  </channel>
</rss>

