<?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: Applying Measure after Multiple Selection in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Applying-Measure-after-Multiple-Selection/m-p/2924227#M95981</link>
    <description>&lt;P&gt;Can you please supply the data set?&lt;/P&gt;</description>
    <pubDate>Wed, 23 Nov 2022 10:48:52 GMT</pubDate>
    <dc:creator>daXtreme</dc:creator>
    <dc:date>2022-11-23T10:48:52Z</dc:date>
    <item>
      <title>Applying Measure after Multiple Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Applying-Measure-after-Multiple-Selection/m-p/2918434#M95639</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Hello All,&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a measure that extrapolates a curve based off the ratio between the latest data point and another line.&amp;nbsp; While it works fine for a single selection, it does not work as intended on multiple selections.&amp;nbsp; I would like the measure to apply/calculate after the selection is done.&amp;nbsp; Hopefully the below pics illustrate my point.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Case 1:&lt;/STRONG&gt; Vacuum selected.&amp;nbsp; '&lt;STRONG&gt;Forecast'&lt;/STRONG&gt; (orange) extrapolates from latest sales data in relation to the &lt;STRONG&gt;'High Sales'&lt;/STRONG&gt; line.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Latest Sale = &lt;/STRONG&gt;Oct. 2022.&lt;STRONG&gt; Latest sale&lt;/STRONG&gt; = 463.&amp;nbsp; &lt;STRONG&gt;High Sales&lt;/STRONG&gt; = 403.&amp;nbsp; &lt;STRONG&gt;Ratio&lt;/STRONG&gt; = 463/405 = 1.149.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Extrapolation keeps that ratio relative to 'High Sales' curve.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Case 2:&lt;/STRONG&gt; Broom selected.&amp;nbsp; &lt;STRONG&gt;'Forecast'&lt;/STRONG&gt; (orange) extrapolates&amp;nbsp; from latest sales data in relation to the &lt;STRONG&gt;'Low Sales'&lt;/STRONG&gt; &amp;amp; &lt;STRONG&gt;'High Sales'&lt;/STRONG&gt; line.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Case 3:&lt;/STRONG&gt; Both Broom and Vacuum selected.&amp;nbsp; &lt;STRONG&gt;'Forecast'&lt;/STRONG&gt; measure does not apply correctly to multiple selection and does not extrapolate from latest sales data.&amp;nbsp;&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;I've linked the DAX measure and sample model below.&amp;nbsp; Please let me know if you have issues accessing it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/s!AndVpJp2VQectCJhCX3lN8mXvlRN?e=nfBRVd" target="_self"&gt;Link to Sample Model&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Forecast =
// Finds latest sales date
VAR EvalDate =
    CALCULATE ( MAX ( SalesActual[Date] ), ALLSELECTED ( SalesActual ) )
VAR BoundaryDate =
    EOMONTH ( TODAY (), -2 ) + 1
VAR Date_ =
    // If latest sales date is older than 2 months, 
    // it will default back to current month.
    IF (
        EvalDate &amp;lt; BoundaryDate,
        BoundaryDate,
        EvalDate
    )
VAR _id =
    CALCULATE ( MAXX ( ALLSELECTED ( SalesHighLow ), [Product] ) )
VAR SalesHistorical =
    CALCULATE (
        [Actual Sales],
        'Calendar'[Date] = Date_,
        SalesHighLow[Product] = _id
    )
VAR SalesHigh =
    CALCULATE (
        // Value of sales high curve @ Date_
        [High Sales],
        'Calendar'[Date] = Date_,
        SalesHighLow[Product] = _id
    )
VAR SalesLow =
    CALCULATE (
        // Value of sales low curve @ Date_
        [Low Sales],
        'Calendar'[Date] = Date_,
        SalesHighLow[Product] = _id
    )
VAR _cat =
    SWITCH (
        TRUE (),
        SalesHistorical &amp;lt;= SalesLow, 1,
        SalesHistorical &amp;lt;= SalesHigh, 2,
        SalesHistorical &amp;gt;= SalesHigh, 3
    )
VAR _result =
    IF (
        MIN ( 'Calendar'[Date] ) &amp;gt;= Date_,
        SWITCH (
            TRUE (),
            // TRUE used as first argument allows SWITCH to replace nested IFs  Cleaner to read. 
            _cat = 1, CALCULATE ( [Low Sales] * DIVIDE ( SalesHistorical, SalesLow ) ),
            _cat = 2,
                CALCULATE (
                    ( [High Sales] * ( SalesHistorical - SalesLow ) + [Low Sales] * ( SalesHigh - SalesHistorical ) ) / ( SalesHigh - SalesLow )
                ),
            _cat = 3,
                CALCULATE ( [High Sales] * ( SalesHistorical / SalesHigh ) )
        )
    )
RETURN
    _result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 10:23:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Applying-Measure-after-Multiple-Selection/m-p/2918434#M95639</guid>
      <dc:creator>Palmtop</dc:creator>
      <dc:date>2022-11-21T10:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Measure after Multiple Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Applying-Measure-after-Multiple-Selection/m-p/2918458#M95640</link>
      <description>&lt;P&gt;If you select many items, then... what is the latest sale date? Is it for broom or the other item? They can have different last sales dates, right? So then, which one do you want to use? This is not as straightforward as you might think. You have to ponder over what you want to do in such cases very thoroughly...&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 10:29:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Applying-Measure-after-Multiple-Selection/m-p/2918458#M95640</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-11-21T10:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Measure after Multiple Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Applying-Measure-after-Multiple-Selection/m-p/2918835#M95669</link>
      <description>&lt;P&gt;Hi daXtreme,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for the help last time.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding the question you pose, I'd like it so that when you select multiple items, you would sum the sales data to get a new dataset/curve (seen in &lt;STRONG&gt;Case 3&lt;/STRONG&gt;) and the measure would treat it as a new independent dataset instead of one which is a sum of 2 others.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would recalculate a ratio, latest sale date, latest sale #, and extrapolate it from there.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, &lt;STRONG&gt;sum cases --&amp;gt; calculate measure&lt;/STRONG&gt; instead of &lt;STRONG&gt;calculate measure for each case --&amp;gt; sum result&lt;/STRONG&gt;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Simpler answer would be whichever is the most recent.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in an example case it would apply the measure to &lt;STRONG&gt;'Total'&lt;/STRONG&gt;&amp;nbsp;taking 04/22 as the latest sale date.&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Broom&lt;/TD&gt;&lt;TD&gt;Vacuum&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Total&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01/22&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02/22&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;15&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;03/22&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;04/22&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;n/a&amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Retaking the original cases, the desired result would look like the yellow line:&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;Please let me know if its still confusing.&amp;nbsp; Thank you.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 13:28:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Applying-Measure-after-Multiple-Selection/m-p/2918835#M95669</guid>
      <dc:creator>Palmtop</dc:creator>
      <dc:date>2022-11-21T13:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Measure after Multiple Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Applying-Measure-after-Multiple-Selection/m-p/2920348#M95753</link>
      <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="456186" data-lia-user-login="Palmtop" class="lia-mention lia-mention-user"&gt;Palmtop&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, you want to update the [Forcast] measure to meet the "Applying Measure after Multiple Selection". Right?&lt;/P&gt;
&lt;P&gt;Here are the steps you can refer to :&lt;/P&gt;
&lt;P&gt;I download you .pbix file and test in&amp;nbsp; my side , you can create a measure to replace your [Forcast] measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Forecast2 = 
// Finds latest sales date
VAR EvalDate =
    CALCULATE(
        MAX ( SalesActual[Date] ),
        ALLSELECTED ( SalesActual )
    )
var BoundaryDate = EOMONTH( TODAY(), -2 ) + 1
VAR Date_ =
    // If latest sales date is older than 2 months, 
    // it will default back to current month.
    IF ( EvalDate &amp;lt; BoundaryDate, 
        BoundaryDate,
        EvalDate
    )
var _id = VALUES('Product'[Product])
VAR SalesHistorical = 
    CALCULATE(
        [Actual Sales],
        'Calendar'[Date] = Date_,
        SalesHighLow[Product] in _id
    )
VAR SalesHigh =
    CALCULATE (
        // Value of sales high curve @ Date_
        [High Sales],
        'Calendar'[Date] = Date_,
        SalesHighLow[Product] in _id
    )
VAR SalesLow =
    CALCULATE (
        // Value of sales low curve @ Date_
        [Low Sales],
        'Calendar'[Date] = Date_,
        SalesHighLow[Product] in _id
    )

var _cat = SWITCH(
                TRUE(),
                SalesHistorical &amp;lt;= SalesLow, 1,
                SalesHistorical &amp;lt;= SalesHigh, 2,
                SalesHistorical &amp;gt;= SalesHigh, 3
                )

var _result = IF ( MIN('Calendar'[Date]) &amp;gt;= Date_, 
    SWITCH ( 
    TRUE(),   // TRUE used as first argument allows SWITCH to replace nested IFs  Cleaner to read. 
    _cat = 1, CALCULATE( [Low Sales] * DIVIDE(SalesHistorical, SalesLow) ),
    _cat = 2, CALCULATE( ( [High Sales] * (SalesHistorical - SalesLow) + [Low Sales] * (SalesHigh - SalesHistorical) ) / (SalesHigh - SalesLow) ) ,
    _cat = 3, CALCULATE( [High Sales] * (SalesHistorical/ SalesHigh) ) 
    )
)

return
    _result&lt;/LI-CODE&gt;
&lt;P&gt;And then we will meet your need:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Aniya Zhang&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; it as the solution&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 04:04:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Applying-Measure-after-Multiple-Selection/m-p/2920348#M95753</guid>
      <dc:creator>v-yueyunzh-msft</dc:creator>
      <dc:date>2022-11-22T04:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Measure after Multiple Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Applying-Measure-after-Multiple-Selection/m-p/2921909#M95828</link>
      <description>&lt;P&gt;Hi Aniya,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Success! Can confirm that worked for me.&amp;nbsp; Thank you &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;For the sake of learning, I'm not understanding why if I replace&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var _id = VALUES('Product'[Product])&lt;/LI-CODE&gt;&lt;P&gt;with&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var _id = VALUES('SalesActual'[Product])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I end up with this chart,&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The product column in all three tables consist of the same 2 distinct values 'Broom' and 'Vacuum' so shouldn't it give identical results regardless of which table I select?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Modelwise too I don't really see a difference.&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;Thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2022 14:05:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Applying-Measure-after-Multiple-Selection/m-p/2921909#M95828</guid>
      <dc:creator>Palmtop</dc:creator>
      <dc:date>2022-11-22T14:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Measure after Multiple Selection</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Applying-Measure-after-Multiple-Selection/m-p/2924227#M95981</link>
      <description>&lt;P&gt;Can you please supply the data set?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 10:48:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Applying-Measure-after-Multiple-Selection/m-p/2924227#M95981</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-11-23T10:48:52Z</dc:date>
    </item>
  </channel>
</rss>

