<?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: store only the first value of a filter and fill the rest with 0 in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/store-only-the-first-value-of-a-filter-and-fill-the-rest-with-0/m-p/2989537#M100518</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="476377" data-lia-user-login="gelsonwj" class="lia-mention lia-mention-user"&gt;gelsonwj&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to add an index column to the power query first.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Column:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Average = 
Var _Aver=CALCULATE(AVERAGE('Table'[Quantity]),ALLEXCEPT('Table','Table'[Date_short]))
Var _minindex=CALCULATE(MIN('Table'[Index]),ALLEXCEPT('Table','Table'[Date_short]))
Return
IF([Index]=_minindex,_Aver,0)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Is this the result you expect?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _Charlotte&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Dec 2022 05:23:09 GMT</pubDate>
    <dc:creator>v-zhangti</dc:creator>
    <dc:date>2022-12-27T05:23:09Z</dc:date>
    <item>
      <title>store only the first value of a filter and fill the rest with 0</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/store-only-the-first-value-of-a-filter-and-fill-the-rest-with-0/m-p/2988877#M100475</link>
      <description>&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create a new column that stores only the first average value of a date and fills the rest with 0. How do I do this?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Dec 2022 13:57:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/store-only-the-first-value-of-a-filter-and-fill-the-rest-with-0/m-p/2988877#M100475</guid>
      <dc:creator>gelsonwj</dc:creator>
      <dc:date>2022-12-26T13:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: store only the first value of a filter and fill the rest with 0</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/store-only-the-first-value-of-a-filter-and-fill-the-rest-with-0/m-p/2988928#M100484</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="476377" data-lia-user-login="gelsonwj" class="lia-mention lia-mention-user"&gt;gelsonwj&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try to add a column with this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Average2 = 
VAR _average = [Average]
VAR _MaxID = 
MAXX(
    FILTER(TableName, TableName[Average] = _average ),
    TableName[id]
)
RETURN
IF( [id] = _MaxID, _average, 0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Dec 2022 14:32:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/store-only-the-first-value-of-a-filter-and-fill-the-rest-with-0/m-p/2988928#M100484</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2022-12-26T14:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: store only the first value of a filter and fill the rest with 0</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/store-only-the-first-value-of-a-filter-and-fill-the-rest-with-0/m-p/2989103#M100500</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="476377" data-lia-user-login="gelsonwj" class="lia-mention lia-mention-user"&gt;gelsonwj&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;First Average =
VAR CurrentID = 'Table'[id]
VAR DateFarmIDTable =
    CALCULATETABLE (
        'Table',
        ALLEXCEPT ( 'Table', 'Table'[Farm_id], 'Table'[Date_short] )
    )
VAR FirstRecord =
    TOPN ( 1, DateFarmIDTable, 'Table'[id] )
VAR MaxID =
    MAXX ( FirstRecord, 'Table'[id] )
VAR FirstAverage =
    MAXX ( FirstRecord, 'Table'[Average] )
RETURN
    IF ( 'Table'[id] = MaxID, FirstAverage, 0 )&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 27 Dec 2022 07:06:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/store-only-the-first-value-of-a-filter-and-fill-the-rest-with-0/m-p/2989103#M100500</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-12-27T07:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: store only the first value of a filter and fill the rest with 0</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/store-only-the-first-value-of-a-filter-and-fill-the-rest-with-0/m-p/2989537#M100518</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="476377" data-lia-user-login="gelsonwj" class="lia-mention lia-mention-user"&gt;gelsonwj&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to add an index column to the power query first.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Column:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Average = 
Var _Aver=CALCULATE(AVERAGE('Table'[Quantity]),ALLEXCEPT('Table','Table'[Date_short]))
Var _minindex=CALCULATE(MIN('Table'[Index]),ALLEXCEPT('Table','Table'[Date_short]))
Return
IF([Index]=_minindex,_Aver,0)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Is this the result you expect?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _Charlotte&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 05:23:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/store-only-the-first-value-of-a-filter-and-fill-the-rest-with-0/m-p/2989537#M100518</guid>
      <dc:creator>v-zhangti</dc:creator>
      <dc:date>2022-12-27T05:23:09Z</dc:date>
    </item>
  </channel>
</rss>

