<?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: Divide values by average of a period of time in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-values-by-average-of-a-period-of-time/m-p/1860676#M39861</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , Not very clear to me. &lt;/P&gt;
&lt;P&gt;For Avg of last 3 months you can try like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example&lt;/P&gt;
&lt;P&gt;Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],eomonth(MAX('Date'[Date]),0),-3,MONTH))/3&lt;/P&gt;</description>
    <pubDate>Mon, 24 May 2021 16:02:33 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2021-05-24T16:02:33Z</dc:date>
    <item>
      <title>Divide values by average of a period of time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-values-by-average-of-a-period-of-time/m-p/1860411#M39850</link>
      <description>&lt;P&gt;Hi,&amp;nbsp; I currently have a bar chart.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- X axis: Year-Month&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- Y axis: count&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;- Legend: categories&amp;nbsp;&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;Where at each x value I have multiple bars, one for each category. I have to divide the count value by the average value of that specific category. I have achieved this with the following DAX command:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;EM&gt;DIVIDE(&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;SUM(programs[count]),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;CALCULATE(AVERAGE(programs[count]), ALLSELECTED(programs[date]))&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/DIV&gt;&lt;P&gt;The problem is that I need to divide all the values by the average of the last three months. I have tried the following but it does not take into account different groups, it calculates the average of the last 3 months but even though the &lt;EM&gt;SUM(programs[count])&lt;/EM&gt; filters by category automatically, the average is calculated on all categories:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;velocity_variance = &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;VAR latest_date = 21.06&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;VAR margin = 3&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;VAR start_date = CONVERT(latest_date - margin, STRING) &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;VAR end_date = CONVERT(latest_date , STRING) &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;VAR velocity = DIVIDE(SUMX(FILTER(programs, AND(programs[data] &amp;gt;= start_date, programs[date] &amp;lt; end_date)), programs[count]), margin) &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;RETURN &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;DIVIDE(&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;SUM(programs[count]),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;velocity &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;Based on this query, I can only think of creating a different average measure for each category but I don't want this because categories will change in the future and I have a lot.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The programs table is of the shape:&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;Count&lt;/TD&gt;&lt;TD&gt;Category&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;20.01&lt;/TD&gt;&lt;TD&gt;34&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;21.12&lt;/TD&gt;&lt;TD&gt;654&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I hope someone can help me!&lt;/P&gt;&lt;P&gt;(sorry about the code, the editor wouldn't let me add syntax highlighting)&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 24 May 2021 13:44:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-values-by-average-of-a-period-of-time/m-p/1860411#M39850</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-05-24T13:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Divide values by average of a period of time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-values-by-average-of-a-period-of-time/m-p/1860676#M39861</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , Not very clear to me. &lt;/P&gt;
&lt;P&gt;For Avg of last 3 months you can try like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example&lt;/P&gt;
&lt;P&gt;Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],eomonth(MAX('Date'[Date]),0),-3,MONTH))/3&lt;/P&gt;</description>
      <pubDate>Mon, 24 May 2021 16:02:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-values-by-average-of-a-period-of-time/m-p/1860676#M39861</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2021-05-24T16:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Divide values by average of a period of time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-values-by-average-of-a-period-of-time/m-p/1861625#M39891</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;Hi, thanks for your help, sorry for the explanation I will explain it better:&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I need to create a bar chart where each value is divided by the average&lt;/P&gt;&lt;P&gt;2. I have done this but I need that the average is only of the last 3 months&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. If I try your method it works but it does the average on all categories not each category individually&amp;nbsp;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 06:38:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-values-by-average-of-a-period-of-time/m-p/1861625#M39891</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-05-25T06:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: Divide values by average of a period of time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-values-by-average-of-a-period-of-time/m-p/1861714#M39894</link>
      <description>&lt;P&gt;Okey, I think the problem is solved, thanks for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 May 2021 07:12:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-values-by-average-of-a-period-of-time/m-p/1861714#M39894</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-05-25T07:12:31Z</dc:date>
    </item>
  </channel>
</rss>

