<?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: Average and Sum in one DAX Measures based on row context in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-and-Sum-in-one-DAX-Measures-based-on-row-context/m-p/2246145#M53927</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column =
IF (
    'Table'[Metric] = "Head Count",
    CALCULATE ( AVERAGE ( 'Table'[Value] ), ALLEXCEPT ( 'Table', 'Table'[Metric] ) ),
    CALCULATE ( SUM ( 'Table'[Value] ), ALLEXCEPT ( 'Table', 'Table'[Metric] ) )
)
&lt;/LI-CODE&gt;</description>
    <pubDate>Sun, 19 Dec 2021 13:10:30 GMT</pubDate>
    <dc:creator>smpa01</dc:creator>
    <dc:date>2021-12-19T13:10:30Z</dc:date>
    <item>
      <title>Average and Sum in one DAX Measures based on row context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-and-Sum-in-one-DAX-Measures-based-on-row-context/m-p/2246125#M53926</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi All,&lt;BR /&gt;I am trying to achieve the values in the expected result column where I want to have an average of Values column where metric is headcount but sum of Values where metric on the row is Sales and Profit?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please help, example is given below.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Two questions;&lt;BR /&gt;1) How can it be achieved it in clculated column?&lt;BR /&gt;2) How can it be achieved through DAX meaure using VAR ?&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Dec 2021 12:42:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-and-Sum-in-one-DAX-Measures-based-on-row-context/m-p/2246125#M53926</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-12-19T12:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Average and Sum in one DAX Measures based on row context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-and-Sum-in-one-DAX-Measures-based-on-row-context/m-p/2246145#M53927</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column =
IF (
    'Table'[Metric] = "Head Count",
    CALCULATE ( AVERAGE ( 'Table'[Value] ), ALLEXCEPT ( 'Table', 'Table'[Metric] ) ),
    CALCULATE ( SUM ( 'Table'[Value] ), ALLEXCEPT ( 'Table', 'Table'[Metric] ) )
)
&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 19 Dec 2021 13:10:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-and-Sum-in-one-DAX-Measures-based-on-row-context/m-p/2246145#M53927</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2021-12-19T13:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Average and Sum in one DAX Measures based on row context</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-and-Sum-in-one-DAX-Measures-based-on-row-context/m-p/2251020#M54196</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I created a sample pbix file(see attachment), please check whether that is what you want. You can create a calculated column or measure as below to get the values:&lt;/P&gt;
&lt;P&gt;1. Create a &lt;STRONG&gt;calculated column&lt;/STRONG&gt; just as suggested by&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="24978" data-lia-user-login="smpa01" class="lia-mention lia-mention-user"&gt;smpa01&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column = 
IF (
    'Table'[Metric] = "Head count",
    CALCULATE (
        AVERAGE ( 'Table'[Values] ),
        ALLEXCEPT ( 'Table', 'Table'[Metric] )
    ),
    CALCULATE ( SUM ( 'Table'[Values] ), ALLEXCEPT ( 'Table', 'Table'[Metric] ) )
)&lt;/LI-CODE&gt;
&lt;P&gt;2. Create a &lt;STRONG&gt;measure&lt;/STRONG&gt; as below&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
VAR _selmetric =
    SELECTEDVALUE ( 'Table'[Metric] )
VAR _average =
    AVERAGEX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Metric] = _selmetric ),
        [Values]
    )
VAR _sum =
    SUMX (
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Metric] = _selmetric ),
        [Values]
    )
RETURN
    IF ( _selmetric = "Head count", _average, _sum )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2021 02:44:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-and-Sum-in-one-DAX-Measures-based-on-row-context/m-p/2251020#M54196</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-12-22T02:44:26Z</dc:date>
    </item>
  </channel>
</rss>

