<?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: How to filter within creation of new table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3152499#M112973</link>
    <description>&lt;P&gt;Wow, that was amazing, that's the code which I was struggling to create.&lt;BR /&gt;&lt;BR /&gt;Big thank you!!&lt;/P&gt;</description>
    <pubDate>Fri, 24 Mar 2023 12:32:17 GMT</pubDate>
    <dc:creator>PawelTr</dc:creator>
    <dc:date>2023-03-24T12:32:17Z</dc:date>
    <item>
      <title>How to filter within creation of new table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3151980#M112928</link>
      <description>&lt;P&gt;Dear PowerBI community,&lt;BR /&gt;&lt;BR /&gt;First of all I would like to say hello, as it's my first post here.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;To my main table, I have attached query which extract sales data aggregated with product, end date of the month, country, section, AVG(price) of the sales, AVG(cost), SUM(quantity of sold articles) and a few another columns, which are not that important here.&lt;BR /&gt;&lt;BR /&gt;I want to create a new table based on previous, but aggregated not on article level.&lt;BR /&gt;&lt;BR /&gt;The code looks similarly to below,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Aggregated = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATETABLE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SUMMARIZ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PAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"Sum_quantity"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Fact_Table[Quantity_sold]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Fact_Table[INVOICE_MONTH_END]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt;= &lt;/SPAN&gt;&lt;SPAN&gt;TODAY&lt;/SPAN&gt;&lt;SPAN&gt;() - &lt;/SPAN&gt;&lt;SPAN&gt;365&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;As you may notice, I want to have the data only for last 365 days. The second filter I would apply is,&amp;nbsp;take into consideration only articles, which were sold in such country, supplier_type, section within all last 12 months.&lt;BR /&gt;&lt;BR /&gt;Maybe someone can help to achieve it?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 08:37:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3151980#M112928</guid>
      <dc:creator>PawelTr</dc:creator>
      <dc:date>2023-03-24T08:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter within creation of new table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3151999#M112932</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="535538" data-lia-user-login="PawelTr" class="lia-mention lia-mention-user"&gt;PawelTr&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Aggregated =
SUMMARIZE (
    FILTER ( Fact_Table, Fact_Table[INVOICE_MONTH_END] &amp;gt;= TODAY () - 365 ),
    Fact_Table[INVOICE_MONTH_END],
    Fact_Table[COUNTRY],
    Fact_Table[SECTION],
    Fact_Table[Supplier_type],
    "Sum_cost_price", SUM ( Fact_Table[Quantity_sold] ) * SUM ( Fact_Table[Cost_Price] ),
    "Sum_selling_price", SUM ( Fact_Table[Quantity_sold] ) * SUM ( Fact_Table[Selling_price] ),
    "Sum_quantity", SUM ( Fact_Table[Quantity_sold] )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 24 Mar 2023 08:46:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3151999#M112932</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-24T08:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter within creation of new table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3152040#M112935</link>
      <description>&lt;P&gt;Thank you tamerj1 for reply!&lt;BR /&gt;&lt;BR /&gt;Maybe I wasn't specific enough, but what I would like to add to the code is to&lt;SPAN&gt;&amp;nbsp;take into consideration only articles, which were sold in such country, supplier_type, section within all last 12 months.&lt;BR /&gt;If no rows exist for article for specific country with e.g. April, it won't be included in the summarize aggregation.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 09:00:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3152040#M112935</guid>
      <dc:creator>PawelTr</dc:creator>
      <dc:date>2023-03-24T09:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter within creation of new table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3152055#M112936</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="535538" data-lia-user-login="PawelTr" class="lia-mention lia-mention-user"&gt;PawelTr&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;And what dose this code do?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 09:07:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3152055#M112936</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-24T09:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter within creation of new table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3152067#M112937</link>
      <description>&lt;P&gt;As I understand it correctly, if sale of article doesn't exist in April, but does in May, quantity will be included in row of May.&lt;BR /&gt;What I'm trying to achieve is,&lt;BR /&gt;sales needs to exist within all last 12 months. If it did not existed during the one, or more of those months, it shouldn't be included in any.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 09:15:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3152067#M112937</guid>
      <dc:creator>PawelTr</dc:creator>
      <dc:date>2023-03-24T09:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter within creation of new table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3152185#M112947</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="535538" data-lia-user-login="PawelTr" class="lia-mention lia-mention-user"&gt;PawelTr&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Aggregated =
VAR T1 =
    FILTER ( Fact_Table, Fact_Table[INVOICE_MONTH_END] &amp;gt;= TODAY () - 365 )
VAR T2 =
    SUMMARIZE (
        T1,
        Fact_Table[Article No.],
        "@CounMonths", COUNTROWS ( VALUES ( Fact_Table[INVOICE_MONTH_END] ) )
    )
VAR T3 =
    FILTER ( T2, [@CounMonths] = 12 )
VAR T4 =
    FILTER ( T1, Fact_Table[Article No.] IN T3 )
VAR Result =
    SUMMARIZE (
        T4,
        Fact_Table[INVOICE_MONTH_END],
        Fact_Table[COUNTRY],
        Fact_Table[SECTION],
        Fact_Table[Supplier_type],
        "Sum_cost_price", SUM ( Fact_Table[Quantity_sold] ) * SUM ( Fact_Table[Cost_Price] ),
        "Sum_selling_price", SUM ( Fact_Table[Quantity_sold] ) * SUM ( Fact_Table[Selling_price] ),
        "Sum_quantity", SUM ( Fact_Table[Quantity_sold] )
    )
RETURN
    Result&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 24 Mar 2023 10:05:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3152185#M112947</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-03-24T10:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter within creation of new table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3152499#M112973</link>
      <description>&lt;P&gt;Wow, that was amazing, that's the code which I was struggling to create.&lt;BR /&gt;&lt;BR /&gt;Big thank you!!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 12:32:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-filter-within-creation-of-new-table/m-p/3152499#M112973</guid>
      <dc:creator>PawelTr</dc:creator>
      <dc:date>2023-03-24T12:32:17Z</dc:date>
    </item>
  </channel>
</rss>

