<?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: Customize table totals in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2416769#M63840</link>
    <description>&lt;P&gt;Thanks for your feedback. Amazing you recreated the table! This is a bit complicated for me so let me look into it before closing the request.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Mar 2022 05:37:31 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-03-25T05:37:31Z</dc:date>
    <item>
      <title>Customize table totals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2402012#M62928</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I have a table with manual entry fields and calculated fields based on other fields. The totals are reflecting the field calulation ginving the wrong result. I explained why I need in the bellow 2 pictures. Thank you for your help in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 01:10:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2402012#M62928</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-18T01:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Customize table totals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2402241#M62941</link>
      <description>&lt;P&gt;HI&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;You try&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Profit Target Measure =
IF (
    HASONEVALUE ( Projects[Project No.] ),
    VALUES ( Projects[Profit target] ),
    DIVIDE ( [Income target], SUM ( Projects[Spendings] ) )
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;Income target =
SUMX (
    VALUES ( Projects[Project No.] ),
    Projects[Profit target] * Projects[Spendings]
)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 18 Mar 2022 03:55:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2402241#M62941</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-18T03:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Customize table totals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2411673#M63539</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a test&amp;nbsp;&lt;SPAN&gt;tamerj1's code, and I think there should be something wrong in it. If your table have duplicate Project No, values function will cause issue. [Income target] measure will show error as well.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;You can try my code as below.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Income target = 
VAR _SUMMARIZE =
    SUMMARIZE (
        Projects,
        Projects[Project No.],
        "Profit target", CALCULATE ( SUM ( Projects[Profit target] ) ),
        "Spending", CALCULATE ( SUM ( Projects[Spending] ) )
    )
VAR _Add_Income_target =
    ADDCOLUMNS ( _SUMMARIZE, "Income target", ( [Profit target] + 1 ) * [Spending] )
RETURN
    SUMX ( _Add_Income_target, [Income target] )&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;M Profit target = 
VAR _Spending =  SUM(Projects[Spending])
VAR _Profit_target = SUM(Projects[Profit target])
Return
IF (
    HASONEVALUE ( Projects[Project No.] ),
    _Profit_target,
    DIVIDE ([Income target]  , _Spending) -1
)&lt;/LI-CODE&gt;
&lt;P&gt;Result is as below.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&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, 23 Mar 2022 08:59:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2411673#M63539</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-23T08:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Customize table totals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2411704#M63542</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thats correct. But what does it mean to have two targets for one project? It means one thing: there is something wrong with data and need to be fixed. In rhis case my code will detect the problem while your sophisticated code will duplicate the income target. Thank you and have a great day!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 09:13:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2411704#M63542</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-23T09:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Customize table totals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2411744#M63544</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your [Income target] is a measure, it will show error because values in filter field.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;If&amp;nbsp;[Income target] is a calculated column, I think it will show incorrect result as below. We can see that Project target will show result as [Project target]*10 due to SUMX, so [Project target]*[Spending] is incorrect.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Then in [Profit Target Measure] , I think &lt;A href="https://docs.microsoft.com/en-us/dax/values-function-dax" target="_self"&gt;values&lt;/A&gt; function will return a column table, I think sum or selectedvalue should be better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 09:27:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2411744#M63544</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-23T09:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Customize table totals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2411825#M63552</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thank you for your reply. Again you are right about the error&amp;nbsp;in the code. I noticed that after I read your first comment. We can simply iterate over the projects table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Income target =
SUMX (
    Projects,
    ( Projects[Profit target] + 1 ) * Projects[Spendings]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will give the same result of your measure in case no duplicates. In case of duplicate project no. your measure sums the spendings and sums the margins then performs the multiplication which&amp;nbsp;I don't know if it has any meaning. It would make sense if there is a requirement to select the MAX or MIN among both the margin&amp;nbsp;and the spending using MAX/MIN instead of SUM. Otherwise I see no reason for complicating the code.&lt;BR /&gt;My approach was based on the assumption that one project has one spending&amp;nbsp;and target which makes complete sense. Therefore this code shall have no issues&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Profit Target Measure =
IF (
    HASONEVALUE ( Projects[Project No.] ),
    VALUES ( Projects[Profit target] ),
    DIVIDE ( [Income target], SUM ( Projects[Spendings] ) )
)&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>Wed, 23 Mar 2022 09:46:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2411825#M63552</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-23T09:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: Customize table totals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2416769#M63840</link>
      <description>&lt;P&gt;Thanks for your feedback. Amazing you recreated the table! This is a bit complicated for me so let me look into it before closing the request.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 05:37:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2416769#M63840</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-25T05:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Customize table totals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2416796#M63843</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;,&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me explain more in details.&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Profit target used to be a conditional column in power query table "dProject", but now I moved it as a measure in the same "dProject". As you can see, this % is manually set because we decide arbritarely how much profit we want. And yes, there are no redundant project codes they are all unique, but they can have the same target. see bellow:&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;can we have a correct calculated total even if the measure itself is manual?&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&amp;nbsp;Income target is cirrectly calculated based on the profit target but not the total.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Let me dig into detail in you proposals&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 05:50:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2416796#M63843</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-25T05:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Customize table totals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2417085#M63856</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You mean to say that the target is a hard coded calculated column. I'm I right?&lt;/P&gt;&lt;P&gt;then the Income target &lt;EM&gt;&lt;STRONG&gt;measure&lt;/STRONG&gt;&lt;/EM&gt; would be&lt;/P&gt;&lt;PRE&gt;Income target =
SUMX (
    Projects,
    ( Projects[Profit target] + 1 ) * Projects[Spendings]
)&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;And the profit would be&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;Profit Target Measure =
IF (
    HASONEVALUE ( Projects[Project No.] ),
    VALUES ( Projects[Profit target] ),
    DIVIDE ( [Income target], SUM ( Projects[Spendings] ) )
)&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 07:57:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2417085#M63856</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-03-25T07:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Customize table totals</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2417612#M63885</link>
      <description>&lt;P&gt;thanks for you help. I actually moved the hardcoded in columns to measure, but i figured out how to customize your proposal.&lt;/P&gt;&lt;P&gt;Thanks again fo you help.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 10:26:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customize-table-totals/m-p/2417612#M63885</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-25T10:26:15Z</dc:date>
    </item>
  </channel>
</rss>

