<?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: Using a measure in DAX in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-measure-in-DAX/m-p/3455666#M131722</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="110507" data-lia-user-login="DominicHill" class="lia-mention lia-mention-user"&gt;DominicHill&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Can you clarify what the issue is &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ? i.e. what result are you currently getting vs what you expect?&lt;/LI&gt;
&lt;LI&gt;In what context are you evaluating the PriceTable expression? Is it one part of a measure or something else?&lt;/LI&gt;
&lt;LI&gt;Regardless of the definition of [Origin Price], its value will not change in any part of the PriceTable expression. In other words, [Origin Price] will be effectively constant for the purpose of the PriceTable expression (unless you want some other behaviour).&lt;/LI&gt;
&lt;LI&gt;The table expression itself looks it should execute fine. I would just recommend simplifying to:&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;PriceTable =
VAR OrigPrice = [Origin Price]
VAR Ratio = 0.8
RETURN
    ADDCOLUMNS (
        GENERATESERIES ( 1, 12, 1 ),
        "Row", [Value],
        "Price", OrigPrice * POWER ( Ratio, [Value] - 1 )
    )
&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;Regards&lt;/P&gt;</description>
    <pubDate>Mon, 02 Oct 2023 08:33:20 GMT</pubDate>
    <dc:creator>OwenAuger</dc:creator>
    <dc:date>2023-10-02T08:33:20Z</dc:date>
    <item>
      <title>Using a measure in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-measure-in-DAX/m-p/3455438#M131709</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have bamboozled myself - I can normally work out most things but this is evading me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code works;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PriceTable =&lt;BR /&gt;ADDCOLUMNS(&lt;BR /&gt;GENERATESERIES(1, 12, 1),&lt;BR /&gt;"Row", [Value],&lt;BR /&gt;"Price",&lt;BR /&gt;IF(&lt;BR /&gt;[Value] = 1,&lt;BR /&gt;[Orig Price],&lt;BR /&gt;SWITCH(&lt;BR /&gt;[Value],&lt;BR /&gt;2, [Orig Price] * 0.80,&lt;BR /&gt;3, [Orig Price] * 0.64,&lt;BR /&gt;4, [Orig Price] * 0.51,&lt;BR /&gt;5, [Orig Price] * 0.41,&lt;BR /&gt;6, [Orig Price] * 0.33,&lt;BR /&gt;7, [Orig Price] * 0.26,&lt;BR /&gt;8, [Orig Price] * 0.21,&lt;BR /&gt;9, [Orig Price] * 0.17,&lt;BR /&gt;10, [Orig Price] * 0.13,&lt;BR /&gt;11, [Orig Price] * 0.11,&lt;BR /&gt;12, [Orig Price] * 0.09&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the problem is that [Orig Price] is a variable and will contain a value from 250 to 3500.&amp;nbsp; The [Orig Price] is a DAX as follows;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Orig Price =&lt;/SPAN&gt; &lt;SPAN&gt;IF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DISTINCTCOUNT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Customer_Port_to_Port_Volumes'&lt;/SPAN&gt;&lt;SPAN&gt;[Region to Region]&lt;/SPAN&gt;&lt;SPAN&gt;) * &lt;/SPAN&gt;&lt;SPAN&gt;250&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;3499&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;3500&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;DISTINCTCOUNT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Customer_Port_to_Port_Volumes'&lt;/SPAN&gt;&lt;SPAN&gt;[Region to Region]&lt;/SPAN&gt;&lt;SPAN&gt;) * &lt;/SPAN&gt;&lt;SPAN&gt;250&lt;/SPAN&gt;&lt;SPAN&gt;) - again I know this works as I can see the values changing.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I appreciate the DAX can not be used as a measure, but I can't find a way forward.&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;All ideas gratefully received!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 02 Oct 2023 05:13:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-measure-in-DAX/m-p/3455438#M131709</guid>
      <dc:creator>DominicHill</dc:creator>
      <dc:date>2023-10-02T05:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using a measure in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-measure-in-DAX/m-p/3455666#M131722</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="110507" data-lia-user-login="DominicHill" class="lia-mention lia-mention-user"&gt;DominicHill&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Can you clarify what the issue is &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ? i.e. what result are you currently getting vs what you expect?&lt;/LI&gt;
&lt;LI&gt;In what context are you evaluating the PriceTable expression? Is it one part of a measure or something else?&lt;/LI&gt;
&lt;LI&gt;Regardless of the definition of [Origin Price], its value will not change in any part of the PriceTable expression. In other words, [Origin Price] will be effectively constant for the purpose of the PriceTable expression (unless you want some other behaviour).&lt;/LI&gt;
&lt;LI&gt;The table expression itself looks it should execute fine. I would just recommend simplifying to:&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;PriceTable =
VAR OrigPrice = [Origin Price]
VAR Ratio = 0.8
RETURN
    ADDCOLUMNS (
        GENERATESERIES ( 1, 12, 1 ),
        "Row", [Value],
        "Price", OrigPrice * POWER ( Ratio, [Value] - 1 )
    )
&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;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 08:33:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-measure-in-DAX/m-p/3455666#M131722</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-10-02T08:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using a measure in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-measure-in-DAX/m-p/3485546#M133372</link>
      <description>&lt;P&gt;Hi Owen,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry I haven't responded before - I have been away.&lt;BR /&gt;&lt;BR /&gt;The code from me generates&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Which if I put into a matrix shows&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The problem is that the first value (the 3,500) should be based on a calculated measure&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;This 'orig price' will change depending on other selections.&amp;nbsp; &amp;nbsp;Then Row 1 of the table should start at whatever is in the calculated measure 'Orig Price', and the remaining rows then calculate.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that make sense?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 12:26:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-measure-in-DAX/m-p/3485546#M133372</guid>
      <dc:creator>DominicHill</dc:creator>
      <dc:date>2023-10-19T12:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using a measure in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-measure-in-DAX/m-p/3488965#M133530</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="110507" data-lia-user-login="DominicHill" class="lia-mention lia-mention-user"&gt;DominicHill&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the clarification &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If &lt;STRONG&gt;Price&lt;/STRONG&gt; needs to update dynamically based on &lt;STRONG&gt;Orig Price&lt;/STRONG&gt; (which is a measure), then &lt;STRONG&gt;Price&lt;/STRONG&gt; must also be a measure.&lt;/P&gt;
&lt;P&gt;This means that &lt;STRONG&gt;Price&lt;/STRONG&gt; cannot be included in a table definition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would sugget creating a table containing the row numbers, then define the measure &lt;STRONG&gt;Price &lt;/STRONG&gt;based on the max value of&amp;nbsp;&lt;STRONG&gt;Row &lt;/STRONG&gt;and &lt;STRONG&gt;Orig Price.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have attached a small example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Row&lt;/STRONG&gt; &lt;STRONG&gt;table&lt;/STRONG&gt; (could be defined in Power Query as well):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Row = 
VAR NumRows = 12
RETURN
    SELECTCOLUMNS (
        GENERATESERIES ( 1, NumRows ),
        "Row", [Value]
    )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Price measure&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Price = 
VAR Ratio = 0.8
VAR OrigPrice = [Orig Price]
VAR CurrentRow = MAX ( 'Row'[Row] )
VAR Result = OrigPrice * POWER ( Ratio, CurrentRow - 1 )
RETURN
    Result&lt;/LI-CODE&gt;
&lt;P&gt;&lt;STRONG&gt;Table visual&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Will that work for what you're doing?&lt;/P&gt;</description>
      <pubDate>Sat, 21 Oct 2023 09:44:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-a-measure-in-DAX/m-p/3488965#M133530</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-10-21T09:44:26Z</dc:date>
    </item>
  </channel>
</rss>

