<?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: ROI on Years in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2316963#M57749</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="347190" data-lia-user-login="icerdeira" class="lia-mention lia-mention-user"&gt;icerdeira&lt;/a&gt;&amp;nbsp;，&lt;/P&gt;
&lt;P&gt;If you want to create a new column,use the below dax:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ROI = 
VAR maxlastyear =
    CALCULATE (
        MAX ( 'Table'[Average Value] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Year] &amp;lt; EARLIER ( 'Table'[Year] ) )
    )
RETURN
    ROUND ( DIVIDE ( 'Table'[Average Value] - maxlastyear, maxlastyear ), 4 )&lt;/LI-CODE&gt;
&lt;P&gt;Final get:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you want to create a measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ROI2 = 
VAR maxlastyear =
    CALCULATE (
        MAX ( 'Table'[Average Value] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Year] &amp;lt; MAX ( 'Table'[Year] ) )
    )
RETURN
    ROUND ( DIVIDE ( max('Table'[Average Value]) - maxlastyear, maxlastyear ), 4 )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did I answer your question? Mark my post as a solution!&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Lucien&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Feb 2022 06:25:19 GMT</pubDate>
    <dc:creator>v-luwang-msft</dc:creator>
    <dc:date>2022-02-03T06:25:19Z</dc:date>
    <item>
      <title>ROI on Years</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2307591#M57219</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need some help on getting the ROI (Return on investment) for Years. The example is Year 2016 = 206.709 € and 2017 = 210.502 the ROI is 1,83%. Is there any way to get the ROI's for 2016/2017, 2017/2018, 2018/2019 ....&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;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Isaac&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2022 12:05:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2307591#M57219</guid>
      <dc:creator>icerdeira</dc:creator>
      <dc:date>2022-01-28T12:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: ROI on Years</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2307611#M57223</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;You can calculate last year's value by using this logic:&lt;BR /&gt;&lt;BR /&gt;LY average =&lt;BR /&gt;&lt;BR /&gt;var _lyear = MAX('Table'[Year])-1 return&lt;BR /&gt;CALCULATE(AVERAGE('Table'[Value]),ALL(Table),Table[Year]=_lyear)&lt;BR /&gt;&lt;BR /&gt;Now you can just use this to calculate the difference&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This year =&amp;nbsp;LY average =&lt;BR /&gt;&lt;BR /&gt;var _year = MAX('Table'[Year]) return&lt;BR /&gt;CALCULATE(AVERAGE('Table'[Value]),ALL(Table),Table[Year]=_lyear)&lt;BR /&gt;&lt;BR /&gt;ROI = DIVIDE([Last Year]-[This Year],[Last Year])&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2022 12:24:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2307611#M57223</guid>
      <dc:creator>ValtteriN</dc:creator>
      <dc:date>2022-01-28T12:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: ROI on Years</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2316963#M57749</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="347190" data-lia-user-login="icerdeira" class="lia-mention lia-mention-user"&gt;icerdeira&lt;/a&gt;&amp;nbsp;，&lt;/P&gt;
&lt;P&gt;If you want to create a new column,use the below dax:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ROI = 
VAR maxlastyear =
    CALCULATE (
        MAX ( 'Table'[Average Value] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Year] &amp;lt; EARLIER ( 'Table'[Year] ) )
    )
RETURN
    ROUND ( DIVIDE ( 'Table'[Average Value] - maxlastyear, maxlastyear ), 4 )&lt;/LI-CODE&gt;
&lt;P&gt;Final get:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you want to create a measure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ROI2 = 
VAR maxlastyear =
    CALCULATE (
        MAX ( 'Table'[Average Value] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Year] &amp;lt; MAX ( 'Table'[Year] ) )
    )
RETURN
    ROUND ( DIVIDE ( max('Table'[Average Value]) - maxlastyear, maxlastyear ), 4 )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did I answer your question? Mark my post as a solution!&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Lucien&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 06:25:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2316963#M57749</guid>
      <dc:creator>v-luwang-msft</dc:creator>
      <dc:date>2022-02-03T06:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: ROI on Years</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2317274#M57765</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your answers, its work. The problem is the year is variable. Its not always = 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 09:09:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2317274#M57765</guid>
      <dc:creator>icerdeira</dc:creator>
      <dc:date>2022-02-03T09:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: ROI on Years</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2318778#M57866</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="347190" data-lia-user-login="icerdeira" class="lia-mention lia-mention-user"&gt;icerdeira&lt;/a&gt;&amp;nbsp;，&lt;/P&gt;
&lt;P&gt;You could also test the below（measure):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;roi3 =
VAR maxyear =
    CALCULATE ( MAX ( 'Table'[Year] ), ALLSELECTED ( 'Table' ) )
VAR minyear =
    CALCULATE ( MIN ( 'Table'[Year] ), ALLSELECTED ( 'Table' ) )
VAR maxvalue =
    CALCULATE (
        MAX ( 'Table'[Average Value] ),
        FILTER ( 'Table', 'Table'[Year] = maxyear )
    )
VAR minvalue =
    CALCULATE (
        MAX ( 'Table'[Average Value] ),
        FILTER ( 'Table', 'Table'[Year] = minyear )
    )
RETURN
    ( maxvalue - minvalue ) / minvalue
&lt;/LI-CODE&gt;
&lt;P&gt;And&amp;nbsp; &amp;nbsp;you can select the year you want to compare:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And not clear about&lt;STRONG&gt;the year is variable. Its not always = 4. &lt;/STRONG&gt;Could you provide a sample data not suit the&amp;nbsp; previous solution i provided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Lucien&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 02:05:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2318778#M57866</guid>
      <dc:creator>v-luwang-msft</dc:creator>
      <dc:date>2022-02-04T02:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: ROI on Years</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2319326#M57892</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The measure is not working. The average is a measure and I think I doesn't work on your measure Roi3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The average measure is Average value = AVERAGE(Table[value])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the table where I have the info&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;This is the value&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Thanks so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IC&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>Fri, 04 Feb 2022 08:32:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2319326#M57892</guid>
      <dc:creator>icerdeira</dc:creator>
      <dc:date>2022-02-04T08:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: ROI on Years</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2324321#M58134</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="347190" data-lia-user-login="icerdeira" class="lia-mention lia-mention-user"&gt;icerdeira&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Accoring your infomation ,it main point the&amp;nbsp; average value is a measure ,not a column.&lt;/P&gt;
&lt;P&gt;I try the following sample data:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;It seems to me that you need to present the averages from the table for the current year, and the averages for [current year - 1 year], and then calculate the roi:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;reaverage = var maxyearlast=CALCULATE(MAX('Table'[year]),FILTER(ALL('Table'),'Table'[year]&amp;lt;MAX('Table'[year])))     return CALCULATE(AVERAGE('Table'[value]),FILTER(ALL('Table'),'Table'[year]=maxyearlast))&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;roi = if('Table'[reaverage]=BLANK(),BLANK(),   DIVIDE('Table'[Average value],'Table'[reaverage])-1)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there are any further questions, you can adjust my template data and present the results you want based on the template data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Lucien&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 02:19:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2324321#M58134</guid>
      <dc:creator>v-luwang-msft</dc:creator>
      <dc:date>2022-02-08T02:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: ROI on Years</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2330411#M58524</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much! It worked, the problem is when I use filters I doesn't work correctly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IC&lt;/P&gt;</description>
      <pubDate>Thu, 10 Feb 2022 09:02:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/ROI-on-Years/m-p/2330411#M58524</guid>
      <dc:creator>icerdeira</dc:creator>
      <dc:date>2022-02-10T09:02:30Z</dc:date>
    </item>
  </channel>
</rss>

