<?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 can I create these calculated measures? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-can-I-create-these-calculated-measures/m-p/2522229#M70389</link>
    <description>&lt;P&gt;Yes! This is what I was looking for. Thank you for helping&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="320777" data-lia-user-login="v-chenwuz-msft" class="lia-mention lia-mention-user"&gt;v-chenwuz-msft&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt; I have 1 more issue that I couldn't figure out yet. I want the sum of profit for total but it is not adding up correctly. At the moment I managed to get the desired output only by creating additional measure:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;new measure = 
SUMX(
    VALUES(report[time]),
    report[profit])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get the correct total sum for profit without creating another measure? Thank you in advance for helping! &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.dropbox.com/s/q0qs0yhydc9fbk6/20220518-powerbi.pbix?dl=0" target="_blank" rel="noopener"&gt;https://www.dropbox.com/s/q0qs0yhydc9fbk6/20220518-powerbi.pbix?dl=0&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 18 May 2022 06:22:08 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-05-18T06:22:08Z</dc:date>
    <item>
      <title>How can I create these calculated measures?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-can-I-create-these-calculated-measures/m-p/2499858#M69087</link>
      <description>&lt;P&gt;Good day, I have difficulty creating these measures and hope to receive help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; This is what I am trying to create:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Profit formula is: &lt;STRONG&gt;factor * multiplier * previous row balance&lt;/STRONG&gt;&lt;BR /&gt;Balance formula is: &lt;STRONG&gt;profit + previous row balance&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Example:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Row 2 profit: 2.5 * 0.01 * 0.99 (or 99%) = 2.48%&lt;/P&gt;&lt;P&gt;Row 2 balance: 2.48% + 99% = 101.48&amp;nbsp;&lt;/P&gt;&lt;P&gt;As there is no previous balance value for the first row, the calculation for row 1 is different!&lt;BR /&gt;Row 1 profit: &lt;STRONG&gt;factor * multiplier * 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Row 1 balance: &lt;STRONG&gt;profit + 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I create these measures? Thank you in advance for taking time to do this! Cheers!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.dropbox.com/s/6bdtvmf5ltbjipi/powerbi.pbix?dl=0" target="_self"&gt;https://www.dropbox.com/s/6bdtvmf5ltbjipi/powerbi.pbix?dl=0&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 May 2022 13:03:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-can-I-create-these-calculated-measures/m-p/2499858#M69087</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-07T13:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create these calculated measures?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-can-I-create-these-calculated-measures/m-p/2501837#M69176</link>
      <description>&lt;P&gt;You could use power query to add the previous balance to the current row, that would make the calculations much simpler and more efficient.&lt;/P&gt;&lt;P&gt;In power query, sort the data by the appropriate column, then add an index column, 0-based. You can then add a new custom column called previous_balance using something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if [index] = 0 then null else #”Added Index”[balance]{[index] – 1}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 09 May 2022 11:28:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-can-I-create-these-calculated-measures/m-p/2501837#M69176</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2022-05-09T11:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create these calculated measures?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-can-I-create-these-calculated-measures/m-p/2506870#M69437</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a bit like a cumulative multiplication algorithm. power bi only supports the calculation of existing data, and cannot perform the next calculation based on its own calculation results. But we can optimize this algorithm.&lt;BR /&gt;Here is the logic of my calculation, you can refer to it.&lt;/P&gt;
&lt;P&gt;assum a&lt;STRONG&gt; = factor * multiplier&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;p2 = b1 + a1&lt;/P&gt;
&lt;P&gt;p3 = b2 + a2&lt;/P&gt;
&lt;P&gt;p4 = b3 + a3&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;b2 = p2+b1&lt;/P&gt;
&lt;P&gt;b3 = p3+b2&lt;/P&gt;
&lt;P&gt;b4 = p4+b3&lt;/P&gt;
&lt;P&gt;so -&amp;gt;&lt;/P&gt;
&lt;P&gt;b2 = b1(1+a2)&lt;/P&gt;
&lt;P&gt;b3 = b1(1+a2)*(1+a3)&lt;/P&gt;
&lt;P&gt;b4 = b1(1+a2)*(1+a3)*(1+a4)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the measures for [balance] and [&lt;SPAN&gt;profit]&amp;nbsp;&lt;/SPAN&gt;is:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;balance =
VAR _b_s =
    SUMMARIZE (
        CALCULATETABLE (
            report,
            FILTER (
                ALLEXCEPT ( report, 'report'[version] ),
                [time] &amp;lt;= MAX ( 'report'[time] )
            )
        ),
        [version],
        [time],
        "fac",
            [multiplier] * SUM ( report[factor] ) + 1
    )
RETURN
    PRODUCTX ( _b_s, [fac] )

profit =
VAR _factor =
    SUM ( report[factor] )
VAR _a = [multiplier] * _factor
VAR _b_s =
    SUMMARIZE (
        CALCULATETABLE (
            report,
            FILTER (
                ALLEXCEPT ( report, 'report'[version] ),
                [time] &amp;lt; MAX ( 'report'[time] )
            )
        ),
        [version],
        [time],
        "fac",
            [multiplier] * SUM ( report[factor] ) + 1
    )
VAR _result =
    PRODUCTX ( _b_s, [fac] ) * _a
RETURN
    IF ( ISBLANK ( _result ), _a, _result )

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Resutl:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pbix in the end you can refer.&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;
&lt;P&gt;Community Support Team _ chenwu zhu&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 07:35:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-can-I-create-these-calculated-measures/m-p/2506870#M69437</guid>
      <dc:creator>v-chenwuz-msft</dc:creator>
      <dc:date>2022-05-11T07:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create these calculated measures?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-can-I-create-these-calculated-measures/m-p/2522229#M70389</link>
      <description>&lt;P&gt;Yes! This is what I was looking for. Thank you for helping&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="320777" data-lia-user-login="v-chenwuz-msft" class="lia-mention lia-mention-user"&gt;v-chenwuz-msft&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt; I have 1 more issue that I couldn't figure out yet. I want the sum of profit for total but it is not adding up correctly. At the moment I managed to get the desired output only by creating additional measure:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;new measure = 
SUMX(
    VALUES(report[time]),
    report[profit])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get the correct total sum for profit without creating another measure? Thank you in advance for helping! &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.dropbox.com/s/q0qs0yhydc9fbk6/20220518-powerbi.pbix?dl=0" target="_blank" rel="noopener"&gt;https://www.dropbox.com/s/q0qs0yhydc9fbk6/20220518-powerbi.pbix?dl=0&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 06:22:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-can-I-create-these-calculated-measures/m-p/2522229#M70389</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-18T06:22:08Z</dc:date>
    </item>
  </channel>
</rss>

