<?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 Measure totals and subtotals incorrect - tried HASONEFILTER but still not working in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-totals-and-subtotals-incorrect-tried-HASONEFILTER-but/m-p/1933781#M42029</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a measure which is grouping fields and then summing.&amp;nbsp; Then taking the average of those summed values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;That works for initial groupings but not for subtotals and grand totals.&amp;nbsp; Need those to calculate average of sums also.&lt;/P&gt;&lt;P&gt;I know there are quite a few explanations of this online - have tried various fixes using HASONEFILTER but haven't worked.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need average of subtotals/totals at the Firm and MatterType level.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help appreciated.&amp;nbsp;&amp;nbsp;&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;ByMatterTypeAndFirm_Average = 
AVERAGEX(
    ADDCOLUMNS(
        SUMMARIZE(
            LT,LT[Firm],LT[Matter],LT[Matter Type]),
        "@Amount", CALCULATE(SUM(LT[Total Amount Billed]))),
    [@Amount]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;</description>
    <pubDate>Thu, 01 Jul 2021 18:14:37 GMT</pubDate>
    <dc:creator>dancarr22</dc:creator>
    <dc:date>2021-07-01T18:14:37Z</dc:date>
    <item>
      <title>Measure totals and subtotals incorrect - tried HASONEFILTER but still not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-totals-and-subtotals-incorrect-tried-HASONEFILTER-but/m-p/1933781#M42029</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a measure which is grouping fields and then summing.&amp;nbsp; Then taking the average of those summed values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;That works for initial groupings but not for subtotals and grand totals.&amp;nbsp; Need those to calculate average of sums also.&lt;/P&gt;&lt;P&gt;I know there are quite a few explanations of this online - have tried various fixes using HASONEFILTER but haven't worked.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need average of subtotals/totals at the Firm and MatterType level.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help appreciated.&amp;nbsp;&amp;nbsp;&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;ByMatterTypeAndFirm_Average = 
AVERAGEX(
    ADDCOLUMNS(
        SUMMARIZE(
            LT,LT[Firm],LT[Matter],LT[Matter Type]),
        "@Amount", CALCULATE(SUM(LT[Total Amount Billed]))),
    [@Amount]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 18:14:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-totals-and-subtotals-incorrect-tried-HASONEFILTER-but/m-p/1933781#M42029</guid>
      <dc:creator>dancarr22</dc:creator>
      <dc:date>2021-07-01T18:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Measure totals and subtotals incorrect - tried HASONEFILTER but still not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-totals-and-subtotals-incorrect-tried-HASONEFILTER-but/m-p/1933891#M42040</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// These helper measures should be hidden.
[_HelperMeasure1] =
    SUM( LT[Total Amount Billed] )
[_HelperMeasure2] = 
    AVERAGEX(
        DISTINCT( LT[Matter Type] ),
        [_HelperMeasure1]
    )
[_HelperMeasure3] =
    AVERAGEX(
        DISTINCT( LT[Firm] ),
        [_HelperMeasure2]
    )

// This measure will work correctly only
// with the hierarchy.
ByMatterTypeAndFirm_Average =
switch( true(),
    // You might need to swap the 2nd and 3rd
    // condition depending on the hierarchy
    // you have. I've assumed you've got
    // a hierarchy of Firm &amp;gt; Matter Type &amp;gt; Matter.
    ISINSCOPE( LT[Matter] ), [_HelperMeasure1],
    ISINSCOPE( LT[Matter Type] ), [_HelperMeasure1],
    ISINSCOPE( LT[Firm] ), [_HelperMeasure2],
    [_HelperMeasure3]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 20:31:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-totals-and-subtotals-incorrect-tried-HASONEFILTER-but/m-p/1933891#M42040</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-07-01T20:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: Measure totals and subtotals incorrect - tried HASONEFILTER but still not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-totals-and-subtotals-incorrect-tried-HASONEFILTER-but/m-p/1935948#M42090</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255913" data-lia-user-login="daxer-almighty" class="lia-mention lia-mention-user"&gt;daxer-almighty&lt;/a&gt;&amp;nbsp; - that fixed it.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;One interesting thing (which I'm not sure about) is for the initial variables which you said to hide - and I did and it worked.&amp;nbsp; Then I tried including them directly in the main formula as VAR(iables) and then referenced those VAR values.&amp;nbsp; But that didn't work.&lt;BR /&gt;Anyways, your solution worked!&amp;nbsp; Appreciate your help.&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 22:44:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-totals-and-subtotals-incorrect-tried-HASONEFILTER-but/m-p/1935948#M42090</guid>
      <dc:creator>dancarr22</dc:creator>
      <dc:date>2021-07-02T22:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Measure totals and subtotals incorrect - tried HASONEFILTER but still not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-totals-and-subtotals-incorrect-tried-HASONEFILTER-but/m-p/1936180#M42110</link>
      <description>&lt;P&gt;&lt;EM&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="32943" data-lia-user-login="dancarr22" class="lia-mention lia-mention-user"&gt;dancarr22&lt;/a&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"One interesting thing (which I'm not sure about) is for the initial variables which you said to hide..."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;They are not variables, they are &lt;STRONG&gt;measures&lt;/STRONG&gt;. A completely different thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"Then I tried including them directly in the main formula as VAR(iables) and then referenced those VAR values.&amp;nbsp; But that didn't work."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That did not work because &lt;STRONG&gt;variables in DAX are static&lt;/STRONG&gt;. Once calculated, they don't change, so applying any filters to them and/or using them in context transition scenarios do not affect their values.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jul 2021 15:10:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-totals-and-subtotals-incorrect-tried-HASONEFILTER-but/m-p/1936180#M42110</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-07-03T15:10:30Z</dc:date>
    </item>
  </channel>
</rss>

