<?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: SUM all rows whilst using a filter in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-all-rows-whilst-using-a-filter/m-p/709656#M1024</link>
    <description>&lt;P&gt;Here's how I accomplished this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Created a Date table and related that to your main table&lt;/LI&gt;&lt;LI&gt;Created two project tables, one related to the table and one not&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Use the column from the "DiscConnProject" table for your slicer&lt;/P&gt;&lt;P&gt;use the project column from the project table for rows on your table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following measures collect the min and max of the project selected:&lt;/P&gt;&lt;PRE&gt;FirstDate of Selected = 
CALCULATE(
    FIRSTDATE( 'Date'[Date] ),
    FILTER( 
        ALL( Table1),    
        SELECTEDVALUE(DiscConnProject[Project] ) = Table1[Project]
    )
)

LastDate of Selected = 
CALCULATE(
    LASTDATE( 'Date'[Date] ),
    FILTER( 
        ALL( Table1),    
        SELECTEDVALUE(DiscConnProject[Project] ) = Table1[Project]
    )
)&lt;/PRE&gt;&lt;P&gt;then a simple total:&lt;/P&gt;&lt;PRE&gt;Total Amt = SUM ( Table1[Amount] )&lt;/PRE&gt;&lt;P&gt;and the last measure:&lt;/P&gt;&lt;PRE&gt;Measure = 
CALCULATE( 
    [Total Amt],
        FILTER( 
            ALL ('Date'[Date]),
       'Date'[Date] &amp;gt;= [FirstDate of Selected]
       &amp;amp;&amp;amp; 'Date'[Date] &amp;lt;= [LastDate of Selected]   
        )
    ,
    ALL( DiscConnProject)
)&lt;/PRE&gt;</description>
    <pubDate>Fri, 07 Jun 2019 18:24:17 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-06-07T18:24:17Z</dc:date>
    <item>
      <title>SUM all rows whilst using a filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-all-rows-whilst-using-a-filter/m-p/709345#M1005</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I have a dataset that looks like this:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Project&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Amount&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;2019-06-06&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;5&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;2019-06-07&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;2019-06-05&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;2019-06-07&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;2019-06-07&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What I want to do, is as follows:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the user to be able to select a project, and see a breakdown of ALL projects and the sum of the amount for each project. So far, so easy. But where I'm struggling is, I need it to only sum the amount for each project, where the amounts fall within the MIN and MAX dates of the &lt;EM&gt;selected &lt;/EM&gt;project.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, for example, if the user selected Project A, we'd get this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Project&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Project Breakdown Amount&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;15&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&amp;nbsp;Earliest date in project A: 2019-06-06&lt;BR /&gt;&amp;nbsp;Latest date in project A: 2019-06-07&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that the amount for Project B should be &lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/FONT&gt;, &lt;I&gt;not&lt;/I&gt;&amp;nbsp; &lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/FONT&gt;, because, although the sum total for Project B (2+3) is 5, the 2 amount was recorded on &lt;SPAN&gt;&lt;STRONG&gt;June 5, which is outside of the date range of the selected project (i.e. June 6 to June 7)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The key is that the min and max dates for the selected project should provide the filter context for the sum of the Amounts for all projects. It must be dynamic, in other words, set by the user (selecting the project).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This is what I have tried&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have tried creating the following measure, but it didn't work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Project Breakdown Amount = 
VAR EarliestDateOfSelectedProject = MIN( [Date] )
VAR LatestDateOfSelectedProject = MAX( [Date] )
RETURN
CALCULATE(    SUM( [Amount] )
            , [Date] &amp;gt;= EarliestDateOfSelectedProject 
            , [Date] &amp;lt;= LatestDateOfSelectedProject 
            , ALL( [Project] )
         )&lt;/PRE&gt;&lt;P&gt;This returns me the total amount of all the projects between the dates, set by the user's Project selection, but it doesn't allow me to break it down by Project, if I include the [Project] column in the table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what it give me when the user selects Project A:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Project selected by user: A&lt;/P&gt;&lt;P&gt;Earliest date of project: 2017-06-06&lt;/P&gt;&lt;P&gt;Latest date of project: 2017-06-07&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Project&lt;/TD&gt;&lt;TD&gt;Project Breakdown Amount&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;20&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This isn't what I want. I want it to return the table I gave above. But it won't do it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me achieve the desired result?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 14:41:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-all-rows-whilst-using-a-filter/m-p/709345#M1005</guid>
      <dc:creator>AltGr9</dc:creator>
      <dc:date>2019-06-07T14:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: SUM all rows whilst using a filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-all-rows-whilst-using-a-filter/m-p/709656#M1024</link>
      <description>&lt;P&gt;Here's how I accomplished this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Created a Date table and related that to your main table&lt;/LI&gt;&lt;LI&gt;Created two project tables, one related to the table and one not&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Use the column from the "DiscConnProject" table for your slicer&lt;/P&gt;&lt;P&gt;use the project column from the project table for rows on your table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following measures collect the min and max of the project selected:&lt;/P&gt;&lt;PRE&gt;FirstDate of Selected = 
CALCULATE(
    FIRSTDATE( 'Date'[Date] ),
    FILTER( 
        ALL( Table1),    
        SELECTEDVALUE(DiscConnProject[Project] ) = Table1[Project]
    )
)

LastDate of Selected = 
CALCULATE(
    LASTDATE( 'Date'[Date] ),
    FILTER( 
        ALL( Table1),    
        SELECTEDVALUE(DiscConnProject[Project] ) = Table1[Project]
    )
)&lt;/PRE&gt;&lt;P&gt;then a simple total:&lt;/P&gt;&lt;PRE&gt;Total Amt = SUM ( Table1[Amount] )&lt;/PRE&gt;&lt;P&gt;and the last measure:&lt;/P&gt;&lt;PRE&gt;Measure = 
CALCULATE( 
    [Total Amt],
        FILTER( 
            ALL ('Date'[Date]),
       'Date'[Date] &amp;gt;= [FirstDate of Selected]
       &amp;amp;&amp;amp; 'Date'[Date] &amp;lt;= [LastDate of Selected]   
        )
    ,
    ALL( DiscConnProject)
)&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Jun 2019 18:24:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SUM-all-rows-whilst-using-a-filter/m-p/709656#M1024</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-06-07T18:24:17Z</dc:date>
    </item>
  </channel>
</rss>

