<?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: DAX formula to get cumulative sales with SELECTEDVALUE in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-get-cumulative-sales-with-SELECTEDVALUE/m-p/3251096#M119965</link>
    <description>&lt;P&gt;Firstly, rather than your current solution you should look into using a fields parameter. they are specifically designed to allow the user to choose which metric to show.&lt;/P&gt;
&lt;P&gt;To solve the problem of being able to toggle between accumulated or not you could use a calculation group with 2 items. The first item would just call SELECTEDMEASURE(), so returning the non-cumulative values. The second calculation item could be&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Cumulative in period =
VAR StartDate =
    CALCULATE ( MIN ( 'Date'[Date] ), ALLSELECTED ( 'Date' ) )
VAR EndDate =
    MAX ( 'Date'[Date] )
VAR Result =
    CALCULATE (
        SELECTEDMEASURE (),
        DATESBETWEEN ( 'Date'[Date], StartDate, EndDate )
    )
RETURN
    Result
&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 24 May 2023 13:03:36 GMT</pubDate>
    <dc:creator>johnt75</dc:creator>
    <dc:date>2023-05-24T13:03:36Z</dc:date>
    <item>
      <title>DAX formula to get cumulative sales with SELECTEDVALUE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-get-cumulative-sales-with-SELECTEDVALUE/m-p/3251007#M119960</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a barchart that will show the cululative total sales over a period of selected months by the user. In the X-axis will be the month(s) and in the Y-axis the sales measure.&lt;/P&gt;&lt;P&gt;My struggling point is that in Y-axis I use so far a measure that includes a&amp;nbsp;SELECTEDVALUE function, since I have a filter with 3 different Sales metrics:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Metric = 
VAR MySelection =
SELECTEDVALUE ( 'Measures'[Selection], "Sales" )
RETURN
SWITCH (
    TRUE (),
    MySelection = "Value", [Sales Value],
    MySelection = "Items", [Sales Items],
    MySelection = "Units", [Sales Units],
    blank()
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how can I convert my DAX code above, in order to get cumulative Sales?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 12:21:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-get-cumulative-sales-with-SELECTEDVALUE/m-p/3251007#M119960</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-05-24T12:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: DAX formula to get cumulative sales with SELECTEDVALUE</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-get-cumulative-sales-with-SELECTEDVALUE/m-p/3251096#M119965</link>
      <description>&lt;P&gt;Firstly, rather than your current solution you should look into using a fields parameter. they are specifically designed to allow the user to choose which metric to show.&lt;/P&gt;
&lt;P&gt;To solve the problem of being able to toggle between accumulated or not you could use a calculation group with 2 items. The first item would just call SELECTEDMEASURE(), so returning the non-cumulative values. The second calculation item could be&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Cumulative in period =
VAR StartDate =
    CALCULATE ( MIN ( 'Date'[Date] ), ALLSELECTED ( 'Date' ) )
VAR EndDate =
    MAX ( 'Date'[Date] )
VAR Result =
    CALCULATE (
        SELECTEDMEASURE (),
        DATESBETWEEN ( 'Date'[Date], StartDate, EndDate )
    )
RETURN
    Result
&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 24 May 2023 13:03:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-get-cumulative-sales-with-SELECTEDVALUE/m-p/3251096#M119965</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-05-24T13:03:36Z</dc:date>
    </item>
  </channel>
</rss>

