<?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 Calling DAX Masters - Price Realization Over Time in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calling-DAX-Masters-Price-Realization-Over-Time/m-p/3143311#M112328</link>
    <description>&lt;P&gt;I've been working on this measure for a long time. Trying to find the best performance. Currently it is not good once you start filtering by Months. Lots of nested iterators and high materialization. I'm starting to think I'm going to have to model this differently.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://1drv.ms/u/s!Amek6H8WmAK0irw1s2fVTctfAZP3TA?e=zAcW1a" target="_self"&gt;I recreated it in Contoso &lt;/A&gt;so you have a model to work with. I need the logic in place that eliminates any rows that don't have positive&amp;nbsp;sales or quantity in either period and in my production model I also have to remove return rows. I also need to evaluate price realization&amp;nbsp;by channel as there can be different discount levels and strategies in different channels for the same product. Thanks in advance for any help or guidance you can spare.&amp;nbsp;&lt;A href="https://1drv.ms/u/s!Amek6H8WmAK0irw1s2fVTctfAZP3TA?e=zAcW1a" target="_self"&gt;Model Download&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Here is the measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Price Realization by Channel = 
VAR YTDTable =
    CALCULATETABLE( DATESYTD( 'Calendar'[DateKey] ), 'Calendar'[DatesInThePast] = TRUE )
VAR PYTDTable =
    CALCULATETABLE(
        SAMEPERIODLASTYEAR( YTDTable ),
        'Calendar'[DatesInThePast] = TRUE
    )
VAR MaterialTable =
   CALCULATETABLE(
        ADDCOLUMNS(
            SUMMARIZE( 'Sales', 'Product'[ProductKey], 'Channel'[Channel]),
            "@ValueYTD", CALCULATE( SUM('Sales'[SalesAmount]), YTDTable ),
            "@QtyYTD", CALCULATE( SUM('Sales'[SalesQuantity]), YTDTable ),
            "@ValuePYTD", CALCULATE( SUM('Sales'[SalesAmount]), PYTDTable ),
            "@QtyPYTD", CALCULATE( SUM('Sales'[SalesQuantity]), PYTDTable )
        ),
        'Sales'[ReturnAmount] = 0
   )
VAR MaterialTable_Filtered =
    FILTER(
        MaterialTable,
        [@ValueYTD] &amp;gt; 0
            &amp;amp;&amp;amp; [@QtyYTD] &amp;gt; 0
            &amp;amp;&amp;amp; [@ValuePYTD] &amp;gt; 0
            &amp;amp;&amp;amp; [@QtyPYTD] &amp;gt; 0
    )
RETURN
    SUMX(
        MaterialTable_Filtered,
        ( DIVIDE( [@ValueYTD], [@QtyYTD] ) - DIVIDE( [@ValuePYTD], [@QtyPYTD] ) ) * [@QtyYTD]
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another approach I tried was SUMX over a Filter and Sumerize. Reduced materialization but required more storage engine queries and as a result performed worse.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Price Realization by Channel 2 = 
VAR YTDTable =
    CALCULATETABLE (
        DATESYTD ( 'Calendar'[DateKey] ),
        'Calendar'[DatesInThePast] = TRUE
    )
VAR PYTDTable =
    CALCULATETABLE (
        SAMEPERIODLASTYEAR ( YTDTable ),
        'Calendar'[DatesInThePast] = TRUE
    )
RETURN
    CALCULATE (
        SUMX (
            FILTER (
                SUMMARIZE ( 'Sales', 'Product'[ProductKey], 'Channel'[Channel] ),
                CALCULATE ( SUM ( 'Sales'[SalesAmount] ), YTDTable ) &amp;gt; 0
                    &amp;amp;&amp;amp; CALCULATE ( SUM ( 'Sales'[SalesQuantity] ), YTDTable ) &amp;gt; 0
                    &amp;amp;&amp;amp; CALCULATE ( SUM ( 'Sales'[SalesAmount] ), PYTDTable ) &amp;gt; 0
                    &amp;amp;&amp;amp; CALCULATE ( SUM ( 'Sales'[SalesQuantity] ), PYTDTable ) &amp;gt; 0
            ),
            (
                (
                    (
                        CALCULATE ( SUM ( 'Sales'[SalesAmount] ), YTDTable )
                            / CALCULATE ( SUM ( 'Sales'[SalesQuantity] ), YTDTable )
                    )
                )
                    - (
                        (
                            CALCULATE ( SUM ( 'Sales'[SalesAmount] ), PYTDTable )
                                / CALCULATE ( SUM ( 'Sales'[SalesQuantity] ), PYTDTable )
                        )
                    )
            )
                * CALCULATE ( SUM ( 'Sales'[SalesQuantity] ), YTDTable )
        ),
        'Sales'[ReturnAmount] = 0
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Mar 2023 20:11:59 GMT</pubDate>
    <dc:creator>n8ball</dc:creator>
    <dc:date>2023-03-20T20:11:59Z</dc:date>
    <item>
      <title>Calling DAX Masters - Price Realization Over Time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calling-DAX-Masters-Price-Realization-Over-Time/m-p/3143311#M112328</link>
      <description>&lt;P&gt;I've been working on this measure for a long time. Trying to find the best performance. Currently it is not good once you start filtering by Months. Lots of nested iterators and high materialization. I'm starting to think I'm going to have to model this differently.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://1drv.ms/u/s!Amek6H8WmAK0irw1s2fVTctfAZP3TA?e=zAcW1a" target="_self"&gt;I recreated it in Contoso &lt;/A&gt;so you have a model to work with. I need the logic in place that eliminates any rows that don't have positive&amp;nbsp;sales or quantity in either period and in my production model I also have to remove return rows. I also need to evaluate price realization&amp;nbsp;by channel as there can be different discount levels and strategies in different channels for the same product. Thanks in advance for any help or guidance you can spare.&amp;nbsp;&lt;A href="https://1drv.ms/u/s!Amek6H8WmAK0irw1s2fVTctfAZP3TA?e=zAcW1a" target="_self"&gt;Model Download&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Here is the measure:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Price Realization by Channel = 
VAR YTDTable =
    CALCULATETABLE( DATESYTD( 'Calendar'[DateKey] ), 'Calendar'[DatesInThePast] = TRUE )
VAR PYTDTable =
    CALCULATETABLE(
        SAMEPERIODLASTYEAR( YTDTable ),
        'Calendar'[DatesInThePast] = TRUE
    )
VAR MaterialTable =
   CALCULATETABLE(
        ADDCOLUMNS(
            SUMMARIZE( 'Sales', 'Product'[ProductKey], 'Channel'[Channel]),
            "@ValueYTD", CALCULATE( SUM('Sales'[SalesAmount]), YTDTable ),
            "@QtyYTD", CALCULATE( SUM('Sales'[SalesQuantity]), YTDTable ),
            "@ValuePYTD", CALCULATE( SUM('Sales'[SalesAmount]), PYTDTable ),
            "@QtyPYTD", CALCULATE( SUM('Sales'[SalesQuantity]), PYTDTable )
        ),
        'Sales'[ReturnAmount] = 0
   )
VAR MaterialTable_Filtered =
    FILTER(
        MaterialTable,
        [@ValueYTD] &amp;gt; 0
            &amp;amp;&amp;amp; [@QtyYTD] &amp;gt; 0
            &amp;amp;&amp;amp; [@ValuePYTD] &amp;gt; 0
            &amp;amp;&amp;amp; [@QtyPYTD] &amp;gt; 0
    )
RETURN
    SUMX(
        MaterialTable_Filtered,
        ( DIVIDE( [@ValueYTD], [@QtyYTD] ) - DIVIDE( [@ValuePYTD], [@QtyPYTD] ) ) * [@QtyYTD]
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another approach I tried was SUMX over a Filter and Sumerize. Reduced materialization but required more storage engine queries and as a result performed worse.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Price Realization by Channel 2 = 
VAR YTDTable =
    CALCULATETABLE (
        DATESYTD ( 'Calendar'[DateKey] ),
        'Calendar'[DatesInThePast] = TRUE
    )
VAR PYTDTable =
    CALCULATETABLE (
        SAMEPERIODLASTYEAR ( YTDTable ),
        'Calendar'[DatesInThePast] = TRUE
    )
RETURN
    CALCULATE (
        SUMX (
            FILTER (
                SUMMARIZE ( 'Sales', 'Product'[ProductKey], 'Channel'[Channel] ),
                CALCULATE ( SUM ( 'Sales'[SalesAmount] ), YTDTable ) &amp;gt; 0
                    &amp;amp;&amp;amp; CALCULATE ( SUM ( 'Sales'[SalesQuantity] ), YTDTable ) &amp;gt; 0
                    &amp;amp;&amp;amp; CALCULATE ( SUM ( 'Sales'[SalesAmount] ), PYTDTable ) &amp;gt; 0
                    &amp;amp;&amp;amp; CALCULATE ( SUM ( 'Sales'[SalesQuantity] ), PYTDTable ) &amp;gt; 0
            ),
            (
                (
                    (
                        CALCULATE ( SUM ( 'Sales'[SalesAmount] ), YTDTable )
                            / CALCULATE ( SUM ( 'Sales'[SalesQuantity] ), YTDTable )
                    )
                )
                    - (
                        (
                            CALCULATE ( SUM ( 'Sales'[SalesAmount] ), PYTDTable )
                                / CALCULATE ( SUM ( 'Sales'[SalesQuantity] ), PYTDTable )
                        )
                    )
            )
                * CALCULATE ( SUM ( 'Sales'[SalesQuantity] ), YTDTable )
        ),
        'Sales'[ReturnAmount] = 0
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 20:11:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calling-DAX-Masters-Price-Realization-Over-Time/m-p/3143311#M112328</guid>
      <dc:creator>n8ball</dc:creator>
      <dc:date>2023-03-20T20:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calling DAX Masters - Price Realization Over Time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calling-DAX-Masters-Price-Realization-Over-Time/m-p/3145970#M112538</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="209208" data-lia-user-login="n8ball" class="lia-mention lia-mention-user"&gt;n8ball&lt;/a&gt;&amp;nbsp; Will Suggest you to change the model and try&amp;nbsp; Pre loading the data as &lt;SPAN&gt;AggregatedSales&amp;nbsp;&lt;/SPAN&gt;table by either on date or by month level&amp;nbsp;granularity&lt;BR /&gt;For eg below&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;AggregatedSales = SUMMARIZE( FILTER(&lt;/SPAN&gt;&lt;SPAN class=""&gt;'Sales'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN class=""&gt;'Sales'&lt;/SPAN&gt;&lt;SPAN&gt;[ReturnAmount] = &lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN class=""&gt;'Product'&lt;/SPAN&gt;&lt;SPAN&gt;[ProductKey], &lt;/SPAN&gt;&lt;SPAN class=""&gt;'Channel'&lt;/SPAN&gt;&lt;SPAN&gt;[Channel], &lt;/SPAN&gt;&lt;SPAN class=""&gt;'Calendar'&lt;/SPAN&gt;&lt;SPAN&gt;[DateKey], &lt;/SPAN&gt;&lt;SPAN class=""&gt;"SalesAmount"&lt;/SPAN&gt;&lt;SPAN&gt;, SUM(&lt;/SPAN&gt;&lt;SPAN class=""&gt;'Sales'&lt;/SPAN&gt;&lt;SPAN&gt;[SalesAmount]), &lt;/SPAN&gt;&lt;SPAN class=""&gt;"SalesQuantity"&lt;/SPAN&gt;&lt;SPAN&gt;, SUM(&lt;/SPAN&gt;&lt;SPAN class=""&gt;'Sales'&lt;/SPAN&gt;&lt;SPAN&gt;[SalesQuantity]) )&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and then create DAX&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;or you can materlize and filter your table which you are doing as pre calculation step&amp;nbsp; in cleansing process and loadit as an Aggregate table , It shall reduce lots of complexity&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Foy dynamic time intelligence you can use something as below article by phil seamark&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://dax.tips/2019/10/09/row-based-time-intelligence/" target="_blank"&gt;https://dax.tips/2019/10/09/row-based-time-intelligence/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;------------------------------------------------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;Linkedn :-https://&lt;A href="http://www.linkedin.com/in/puneet-v-376470135/" target="_blank" rel="noopener"&gt;www.linkedin.com/in/puneet-v-376470135/&lt;/A&gt;&lt;BR /&gt;Youtube :-https://&lt;A href="http://www.youtube.com/@datatrends101" target="_blank" rel="noopener"&gt;www.youtube.com/@datatrends101&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 00:06:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calling-DAX-Masters-Price-Realization-Over-Time/m-p/3145970#M112538</guid>
      <dc:creator>puneetvijwani</dc:creator>
      <dc:date>2023-03-22T00:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calling DAX Masters - Price Realization Over Time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calling-DAX-Masters-Price-Realization-Over-Time/m-p/3148058#M112697</link>
      <description>&lt;P&gt;Yup. I will have to try to generate a price table. The only issue there is you loose the dynamic nature of the measure. I think we would need to wrap the SUMs you have above in a CALCULATE to perform context transition to get the right result. Also would need do YTD and PYTD calc for each date.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 18:40:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calling-DAX-Masters-Price-Realization-Over-Time/m-p/3148058#M112697</guid>
      <dc:creator>n8ball</dc:creator>
      <dc:date>2023-03-22T18:40:08Z</dc:date>
    </item>
  </channel>
</rss>

