<?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: Any possibility to optimize below DAX query to use in SSAS Tabular Cube? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Any-possibility-to-optimize-below-DAX-query-to-use-in-SSAS/m-p/4004969#M156342</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="751906" data-lia-user-login="KoppulaPSR" class="lia-mention lia-mention-user"&gt;KoppulaPSR&lt;/a&gt;&amp;nbsp;In your date table create a column that will act as a contiguous Year Month Number since 1899-12-30,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code for the column will be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Dates[Year] * 12 + Dates[Month Number]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then you just to filter last 12 Year Month Numbers using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR ActiveYearMonthNumber = 
    MAX ( Dates[Year Month Number] )
VAR Result =
    CALCULATE ( 
        [Total Sales],
        Dates[Year Month Number] &amp;gt;= ActiveYearMonthNumber - 12
            &amp;amp;&amp;amp; Dates[Year Month Number] &amp;lt; ActiveYearMonthNumber,
        REMOVEFILTERS ( Dates )
    )
RETURN 
    Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This calculation will be just like writing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE ( 
    [Total Sales],
    PARALLELPERIOD ( Dates[Date], -1, MONTH )
)

...

+ 
CALCULATE ( 
    [Total Sales],
    PARALLELPERIOD ( Dates[Date], -12, MONTH )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you don't want grand total then you can add ISINSCOPE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;IF ( 
    ISINSCOPE ( Dates[Year] ), -- Whatever is the top level column in the visual
    VAR ActiveYearMonthNumber = 
        MAX ( Dates[Year Month Number] )
    VAR Result =
        CALCULATE ( 
            [Total Sales],
            Dates[Year Month Number] &amp;gt;= ActiveYearMonthNumber - 12
                &amp;amp;&amp;amp; Dates[Year Month Number] &amp;lt; ActiveYearMonthNumber,
            REMOVEFILTERS ( Dates )
        )
    RETURN 
        Result
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want additive sub totals and grand total then you can use SUMX.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SUMX ( 
    VALUES ( Dates[Year Month Number] ),
    VAR ActiveYearMonthNumber = 
        Dates[Year Month Number]
    VAR Result =
        CALCULATE ( 
            [Total Sales],
            Dates[Year Month Number] &amp;gt;= ActiveYearMonthNumber - 12
                &amp;amp;&amp;amp; Dates[Year Month Number] &amp;lt; ActiveYearMonthNumber,
            REMOVEFILTERS ( Dates )
        )
    RETURN 
        Result
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 22 Jun 2024 11:42:44 GMT</pubDate>
    <dc:creator>AntrikshSharma</dc:creator>
    <dc:date>2024-06-22T11:42:44Z</dc:date>
    <item>
      <title>Any possibility to optimize below DAX query to use in SSAS Tabular Cube?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Any-possibility-to-optimize-below-DAX-query-to-use-in-SSAS/m-p/4004961#M156333</link>
      <description>&lt;P&gt;Dear Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to check, whether we can tune below 2 queries w.r.t perfomance improvment. Presently both queries are executing in ~80 seconds which is impacting my over all report rferesh cycle. Kinldy advise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below query i use as a part of Month Over Month Calulcation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[12MonthTotalMoM] :=
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-1,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-2,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-3,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-4,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-5,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-6,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-7,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-8,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-9,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-10,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-11,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-12,MONTH))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below query i use as a part of Year Over Year Calulcation. Where i take previous year rolling 12 months.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[12MonthTotalYoY] :=
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-12,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-13,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-14,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-15,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-16,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-17,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-18,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-19,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-20,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-21,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-22,MONTH))+
CALCULATE([NrrCustomerRevenueCurrentPeriod],PARALLELPERIOD('Time'[EisPeriodName],-23,MONTH))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jun 2024 10:58:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Any-possibility-to-optimize-below-DAX-query-to-use-in-SSAS/m-p/4004961#M156333</guid>
      <dc:creator>KoppulaPSR</dc:creator>
      <dc:date>2024-06-22T10:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: Any possibility to optimize below DAX query to use in SSAS Tabular Cube?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Any-possibility-to-optimize-below-DAX-query-to-use-in-SSAS/m-p/4004969#M156342</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="751906" data-lia-user-login="KoppulaPSR" class="lia-mention lia-mention-user"&gt;KoppulaPSR&lt;/a&gt;&amp;nbsp;In your date table create a column that will act as a contiguous Year Month Number since 1899-12-30,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code for the column will be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Dates[Year] * 12 + Dates[Month Number]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then you just to filter last 12 Year Month Numbers using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR ActiveYearMonthNumber = 
    MAX ( Dates[Year Month Number] )
VAR Result =
    CALCULATE ( 
        [Total Sales],
        Dates[Year Month Number] &amp;gt;= ActiveYearMonthNumber - 12
            &amp;amp;&amp;amp; Dates[Year Month Number] &amp;lt; ActiveYearMonthNumber,
        REMOVEFILTERS ( Dates )
    )
RETURN 
    Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This calculation will be just like writing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE ( 
    [Total Sales],
    PARALLELPERIOD ( Dates[Date], -1, MONTH )
)

...

+ 
CALCULATE ( 
    [Total Sales],
    PARALLELPERIOD ( Dates[Date], -12, MONTH )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you don't want grand total then you can add ISINSCOPE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;IF ( 
    ISINSCOPE ( Dates[Year] ), -- Whatever is the top level column in the visual
    VAR ActiveYearMonthNumber = 
        MAX ( Dates[Year Month Number] )
    VAR Result =
        CALCULATE ( 
            [Total Sales],
            Dates[Year Month Number] &amp;gt;= ActiveYearMonthNumber - 12
                &amp;amp;&amp;amp; Dates[Year Month Number] &amp;lt; ActiveYearMonthNumber,
            REMOVEFILTERS ( Dates )
        )
    RETURN 
        Result
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want additive sub totals and grand total then you can use SUMX.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SUMX ( 
    VALUES ( Dates[Year Month Number] ),
    VAR ActiveYearMonthNumber = 
        Dates[Year Month Number]
    VAR Result =
        CALCULATE ( 
            [Total Sales],
            Dates[Year Month Number] &amp;gt;= ActiveYearMonthNumber - 12
                &amp;amp;&amp;amp; Dates[Year Month Number] &amp;lt; ActiveYearMonthNumber,
            REMOVEFILTERS ( Dates )
        )
    RETURN 
        Result
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jun 2024 11:42:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Any-possibility-to-optimize-below-DAX-query-to-use-in-SSAS/m-p/4004969#M156342</guid>
      <dc:creator>AntrikshSharma</dc:creator>
      <dc:date>2024-06-22T11:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Any possibility to optimize below DAX query to use in SSAS Tabular Cube?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Any-possibility-to-optimize-below-DAX-query-to-use-in-SSAS/m-p/4005018#M156357</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="236628" data-lia-user-login="AntrikshSharma" class="lia-mention lia-mention-user"&gt;AntrikshSharma&lt;/a&gt;&amp;nbsp;Your idea is brilliant, now i have used exited ID column in time dimension, which i created with Key Identity. Post impelmentation report refresh cycle reduced by 30%. Needs to tune further of another metrics as well.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jun 2024 13:12:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Any-possibility-to-optimize-below-DAX-query-to-use-in-SSAS/m-p/4005018#M156357</guid>
      <dc:creator>KoppulaPSR</dc:creator>
      <dc:date>2024-06-22T13:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Any possibility to optimize below DAX query to use in SSAS Tabular Cube?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Any-possibility-to-optimize-below-DAX-query-to-use-in-SSAS/m-p/4006558#M156841</link>
      <description>&lt;P&gt;HI,&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="751906" data-lia-user-login="KoppulaPSR" class="lia-mention lia-mention-user"&gt;KoppulaPSR&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Can you tell me if your problem is solved? If yes, please accept it as solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Leroy Lu&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 08:55:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Any-possibility-to-optimize-below-DAX-query-to-use-in-SSAS/m-p/4006558#M156841</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-24T08:55:42Z</dc:date>
    </item>
  </channel>
</rss>

