<?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 measure for sum of average by grouping in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-for-sum-of-average-by-grouping/m-p/1034100#M13680</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SUMX(
	SUMMARIZE(
		FT,
		FT[Group],
		FT[Year]
	),
	CALCULATE(
		SUMX(
			VALUES( FactTable[Value] ),
			FactTable[Value]
		)
	)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even though the above works, I'm afraid it could sometimes return incorrect results. &lt;STRONG&gt;Anything (the above formula from Greg included)&lt;/STRONG&gt;&amp;nbsp;that you calculate on a single fact table CAN return an incorrect result as the below article explains:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/understanding-dax-auto-exist/" target="_blank" rel="noopener"&gt;https://www.sqlbi.com/articles/understanding-dax-auto-exist/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore, you should create a star-schema as the model for your data. Don't do it and you'll be creating wrong figures you will not even be aware of.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your model is correct, then this will do what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SUMX(
	SUMMARIZE(
		FT,
		Groups[Group],
		Calendar[Year]
	),
	CALCULATE(
		SUMX(
			VALUES( FactTable[Value] ),
			FactTable[Value]
		)
	)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
    <pubDate>Sat, 18 Apr 2020 16:36:20 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-04-18T16:36:20Z</dc:date>
    <item>
      <title>DAX measure for sum of average by grouping</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-for-sum-of-average-by-grouping/m-p/1033448#M13658</link>
      <description>&lt;P&gt;Hi everyone, I'm looking for help creating this DAX measure after spending some time trying my own solutions and search online for something similar, to no avail. Here what my starting table looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Group&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Year&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Year-Quarter&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Value&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A1&lt;/TD&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2019Q3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A1&lt;/TD&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;2019Q4&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A1&lt;/TD&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;2020Q1&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A2&lt;/TD&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2019Q3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A2&lt;/TD&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;2019Q4&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A2&lt;/TD&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;2020Q1&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;B1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2019Q3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B1&lt;/TD&gt;&lt;TD&gt;2019&lt;/TD&gt;&lt;TD&gt;2019Q4&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B1&lt;/TD&gt;&lt;TD&gt;2020&lt;/TD&gt;&lt;TD&gt;2020Q1&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For a given &lt;STRONG&gt;Group&lt;/STRONG&gt;, for a given &lt;STRONG&gt;Year&lt;/STRONG&gt;, the &lt;STRONG&gt;Value&lt;/STRONG&gt; field will be duplicated for each quarter. I need to create a measure that gives my the sum of the&amp;nbsp;&lt;STRONG&gt;Value&lt;/STRONG&gt; column by each unique Year-Group combo. The simplest example is if I have a slicer with A1 selected and a date slider filtering on 2019Q3-2019Q4, the DAX measure should output 30. A slightly more complicated example is&amp;nbsp;if I have a slicer filtering for A1 and A2, and a date slider with 2019Q3-2019Q4 selected, the measure should output 33, since that is the sum of the unique Year-Group values. I've tried all manner of CALCULATE, SUMX, and GROUPBY statements and really am not getting anywhere. Any ideas? I'm sure there is a simple answer, thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 22:10:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-for-sum-of-average-by-grouping/m-p/1033448#M13658</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-17T22:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure for sum of average by grouping</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-for-sum-of-average-by-grouping/m-p/1033651#M13665</link>
      <description>&lt;P&gt;I would think:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure =
VAR __Table = 
  SUMMARIZE(
    'Table',
    [Group],
    [Year],
    "Value",AVERAGE([Value])
  )
RETURN
  SUMX(__Table,[Value])&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 18 Apr 2020 03:58:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-for-sum-of-average-by-grouping/m-p/1033651#M13665</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-04-18T03:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure for sum of average by grouping</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-for-sum-of-average-by-grouping/m-p/1034100#M13680</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SUMX(
	SUMMARIZE(
		FT,
		FT[Group],
		FT[Year]
	),
	CALCULATE(
		SUMX(
			VALUES( FactTable[Value] ),
			FactTable[Value]
		)
	)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even though the above works, I'm afraid it could sometimes return incorrect results. &lt;STRONG&gt;Anything (the above formula from Greg included)&lt;/STRONG&gt;&amp;nbsp;that you calculate on a single fact table CAN return an incorrect result as the below article explains:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.sqlbi.com/articles/understanding-dax-auto-exist/" target="_blank" rel="noopener"&gt;https://www.sqlbi.com/articles/understanding-dax-auto-exist/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore, you should create a star-schema as the model for your data. Don't do it and you'll be creating wrong figures you will not even be aware of.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your model is correct, then this will do what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SUMX(
	SUMMARIZE(
		FT,
		Groups[Group],
		Calendar[Year]
	),
	CALCULATE(
		SUMX(
			VALUES( FactTable[Value] ),
			FactTable[Value]
		)
	)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Sat, 18 Apr 2020 16:36:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-for-sum-of-average-by-grouping/m-p/1034100#M13680</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-18T16:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: DAX measure for sum of average by grouping</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-for-sum-of-average-by-grouping/m-p/1037312#M13836</link>
      <description>&lt;P&gt;Excellent, this works perfectly. Regarding the model, this table is being sliced by a series of master tables in a star format so I think there should be no issues there. I'm still learning about how to build good data relationships and DAX as well so all of this is helpful! DAX measures in particular are difficult to wrap my head around...&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2020 17:51:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-measure-for-sum-of-average-by-grouping/m-p/1037312#M13836</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-04-20T17:51:19Z</dc:date>
    </item>
  </channel>
</rss>

