<?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: Struggling with simple calculation &amp;amp; context transition in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Struggling-with-simple-calculation-amp-context-transition/m-p/4254009#M168507</link>
    <description>&lt;P&gt;Thank you for your effort. In your example the count is correct, however the more relevant measure "Sum averaged values" is not. For category A it should be 22.5 and not 30.&lt;BR /&gt;&lt;BR /&gt;Furthermore I feel like the measures you propose are too complex for the simple calculation which I want to achieve. I guess that I haven't explained my issue accurately.&lt;BR /&gt;&lt;BR /&gt;My main goal is to:&lt;BR /&gt;&lt;SPAN&gt;For each observation in the fact table sum the value in colum Value divided by the number of observations with the same value in the Group column&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;within a selected time period&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;(for example by an external slicer)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;Maybe I need to do some more experimentation myself and try to explain my issue better.&lt;BR /&gt;Nevertheless, thank you for your support.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Oct 2024 08:59:18 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-10-23T08:59:18Z</dc:date>
    <item>
      <title>Struggling with simple calculation &amp; context transition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Struggling-with-simple-calculation-amp-context-transition/m-p/4247023#M168143</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've reached a mental roadblock. Any help would be greatly appreciated. Here is a sample file with my issue:&amp;nbsp;&lt;A href="https://1drv.ms/u/s!AunGMHyoM0IkgtJZcAl4P4AfPb8TNg?e=yFzJd3" target="_blank"&gt;Example_Conext_Transition.pbix&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;My data model consists of a fact table with observations, a date dimension an category dimension.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The sample data looks like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I want to calculate the following:&lt;BR /&gt;&lt;BR /&gt;For each observation in the fact table sum its value divided by the number of observations of the same group &lt;STRONG&gt;within the selected time period&lt;/STRONG&gt;&amp;nbsp;(detailed example below).&lt;BR /&gt;&lt;BR /&gt;This is the DAX formula I tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Sum averaged Value = 
    SUMX(FactObservations,
    FactObservations[Value] / 
    CALCULATE(
            [# Observations],
            REMOVEFILTERS(FactObservations),
			VALUES(FactObservations[Group]),
            VALUES('Date'[Month])
			)
		)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;while "# Observations" is just:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;COUNTROWS(FactObservations)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;To test if the observations are counted corectly I also created a measure "SUMX group count" which is basically the same formula as "Sum aggregated value" just without the division:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;SUMX(
	FactObservations,
	CALCULATE(
		[# Observations],
		REMOVEFILTERS(FactObservations),
		VALUES(FactObservations[Group]),
		VALUES('Date'[Month])
	)
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In the screenshot below you can see, that I selected Month 1 in the slicer and the "SUMX group count" measure correctly counts the number of "Group 1" observations in this month (which is 2).&lt;BR /&gt;Furthermore it correctly calculates the averaged value, so for example in the first row: Value 10 / 2 observations = 5.&lt;BR /&gt;&lt;BR /&gt;However, if I try to aggregate the "Sum averaged Value" in the donut chart by Category (see red highlights) I would expect the value for Category A to be 5 + 10 + 7,5 = 22.5 . Instead the value is 11.25 - so exactly half.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;What am I doing wrong? How should the Dax formula look like and why?&lt;BR /&gt;&lt;BR /&gt;Thank you for your support. I can upload the sample file if needed.&lt;BR /&gt;Best regards&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2024 06:43:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Struggling-with-simple-calculation-amp-context-transition/m-p/4247023#M168143</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-18T06:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Struggling with simple calculation &amp; context transition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Struggling-with-simple-calculation-amp-context-transition/m-p/4247312#M168163</link>
      <description>&lt;P&gt;You omitted quite a few details. What's your formula for [# Observations] ? Something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# Observations = CALCULATE(COUNTROWS(FactObservations),ALLEXCEPT(FactObservations,FactObservations[Group]))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is your formula for SUMX Group Count?&amp;nbsp; Something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SUMX group count = 
var g = ADDCOLUMNS(VALUES(FactObservations[Group]),"cr",var gr=[Group] return COUNTROWS(filter(ALLSELECTED(FactObservations),[Group]=gr)))
return sumx(g,[cr])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the totals on your version are incorrect.&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;It is generally not advisable to use columns from your fact table for visuals. You are missing a Groups dimension table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2024 22:20:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Struggling-with-simple-calculation-amp-context-transition/m-p/4247312#M168163</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-10-17T22:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: Struggling with simple calculation &amp; context transition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Struggling-with-simple-calculation-amp-context-transition/m-p/4247757#M168176</link>
      <description>&lt;P&gt;Thank you for the feedback. I added the formulas to my original post. I also added a sample file.&lt;BR /&gt;What might be the correct dax formula?&lt;BR /&gt;Thanks for your support&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2024 06:46:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Struggling-with-simple-calculation-amp-context-transition/m-p/4247757#M168176</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-18T06:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Struggling with simple calculation &amp; context transition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Struggling-with-simple-calculation-amp-context-transition/m-p/4248574#M168215</link>
      <description>&lt;P&gt;Your SUMX Group Count totals are incorrect.&amp;nbsp; Should be 5, not 25&lt;/P&gt;
&lt;P&gt;You are walking on very thin ice here.&amp;nbsp; Usually attributes from the fact table should not be used for grouping.&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;</description>
      <pubDate>Fri, 18 Oct 2024 16:09:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Struggling-with-simple-calculation-amp-context-transition/m-p/4248574#M168215</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-10-18T16:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Struggling with simple calculation &amp; context transition</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Struggling-with-simple-calculation-amp-context-transition/m-p/4254009#M168507</link>
      <description>&lt;P&gt;Thank you for your effort. In your example the count is correct, however the more relevant measure "Sum averaged values" is not. For category A it should be 22.5 and not 30.&lt;BR /&gt;&lt;BR /&gt;Furthermore I feel like the measures you propose are too complex for the simple calculation which I want to achieve. I guess that I haven't explained my issue accurately.&lt;BR /&gt;&lt;BR /&gt;My main goal is to:&lt;BR /&gt;&lt;SPAN&gt;For each observation in the fact table sum the value in colum Value divided by the number of observations with the same value in the Group column&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;within a selected time period&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;(for example by an external slicer)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;Maybe I need to do some more experimentation myself and try to explain my issue better.&lt;BR /&gt;Nevertheless, thank you for your support.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2024 08:59:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Struggling-with-simple-calculation-amp-context-transition/m-p/4254009#M168507</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-23T08:59:18Z</dc:date>
    </item>
  </channel>
</rss>

