<?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: Subtracting two rows based on conditions in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2420559#M64105</link>
    <description>&lt;P&gt;Hi HotChilli,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Just to clarify what you are stating - The logic is that if SecurityID in PortfolioNbr 150 is present, then sum it in 110 or 120 respectively (this depends whether the SecurityID is in 110 or 120).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Yes PortfolioNbr and Holdingvalue is hardcoded and calculated from another system.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for your response &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;Let me know if everything else is required from me.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Mar 2022 06:54:18 GMT</pubDate>
    <dc:creator>Solle</dc:creator>
    <dc:date>2022-03-28T06:54:18Z</dc:date>
    <item>
      <title>Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2417933#M63912</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;As I have started to use PowerBI I have stumbled upon a problem, in which I haven't been able to find any posts or useful answers to.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have the following columns which is used as rows in the report presented:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Aktivklasse (Top level info)&lt;/LI&gt;&lt;LI&gt;AltPortfolioName (Sub level info)&lt;/LI&gt;&lt;LI&gt;PortfolioNbr (Sub level info)&lt;/LI&gt;&lt;LI&gt;InstrumentSecurityID (Sub-sub level)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Beside that I have an [AsOfDate] which will be used in a slicer&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;The problem&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;My data looks like this&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Aktivklasse&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;AltPortfolioName&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;PortfolioNbr&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;InstrumentSecurityID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Holding Value&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Repo&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Repo&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;150&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#339966"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#339966"&gt;EU000x0000&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&g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t;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;120&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#00CCFF"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#00CCFF"&gt;DK000x0000&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;What I want to do is to SUM the [Holding Value] for each [InstrumentSecurityID] in [Aktivklasse] = Repo in either [PortfolioNbr] = 110 or [PortfolioNbr] = 120 depending on if the [InstrumentSecurityID] is present in the respective portfolio - Does anyone have a solution to this? The table I would like should be like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Aktivklasse&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;AltPortfolioName&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;PortfolioNbr&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;InstrumentSecurityID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Holding Value&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Repo&lt;/TD&gt;&lt;TD&gt;&amp;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t;&lt;FONT color="#339966"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#339966"&gt;EU000x0000&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;350&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bonds&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Bonds DK&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;120&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#00CCFF"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#00CCFF"&gt;DK000x0000&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;600&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;I have marked the part of the table which have changed to the sum. It is not necessarily needed for me to contain the repo data but it would be nice.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Please let me know if anything else is required or needs to be explained.&lt;BR /&gt;&lt;BR /&gt;Thank you in advance.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 12:42:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2417933#M63912</guid>
      <dc:creator>Solle</dc:creator>
      <dc:date>2022-03-25T12:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2418068#M63914</link>
      <description>&lt;P&gt;Is the logic "if portfolionbr is 110 or 120 then sum the holding value for the same securityID, else holding value",&lt;/P&gt;
&lt;P&gt;i.e. is the portfolionbr hardcoded to those 2 values?&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 13:53:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2418068#M63914</guid>
      <dc:creator>HotChilli</dc:creator>
      <dc:date>2022-03-25T13:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2420559#M64105</link>
      <description>&lt;P&gt;Hi HotChilli,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Just to clarify what you are stating - The logic is that if SecurityID in PortfolioNbr 150 is present, then sum it in 110 or 120 respectively (this depends whether the SecurityID is in 110 or 120).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Yes PortfolioNbr and Holdingvalue is hardcoded and calculated from another system.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for your response &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;Let me know if everything else is required from me.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 06:54:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2420559#M64105</guid>
      <dc:creator>Solle</dc:creator>
      <dc:date>2022-03-28T06:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2421457#M64165</link>
      <description>&lt;P&gt;Here's a column:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ColumnG = IF (TableR[PortfolioNbr] IN {110, 120}, CALCULATE(SUM(TableR[Holding Value]), ALLEXCEPT(TableR, TableR[InstrumentSecurityID])), TableR[Holding Value])&lt;/LI-CODE&gt;
&lt;P&gt;and that will work for the data as shown.&lt;/P&gt;
&lt;P&gt;Maybe if the real data is more complex it might need some changes but see how your testing goes.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 12:12:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2421457#M64165</guid>
      <dc:creator>HotChilli</dc:creator>
      <dc:date>2022-03-28T12:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2421753#M64188</link>
      <description>&lt;P&gt;Hi again,&amp;nbsp;&lt;BR /&gt;Thank you for your fast reply - The provided code seem to be applied to all the other portfolios as well.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Beside the portfolios shown above, the same securityID might be present i.e. portfolio number 171, but what I need is the sum of portfolio 156 split upon securityID and then across portfolio number 110 and 120&lt;BR /&gt;&lt;BR /&gt;Do you have any suggestions for this to work?&lt;BR /&gt;&lt;BR /&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 13:51:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2421753#M64188</guid>
      <dc:creator>Solle</dc:creator>
      <dc:date>2022-03-28T13:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2424086#M64320</link>
      <description>&lt;P&gt;How do we know that 110 and 120 are connected to portfolio 156 (did you mean 150?) and not connected to 171?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 11:36:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2424086#M64320</guid>
      <dc:creator>HotChilli</dc:creator>
      <dc:date>2022-03-29T11:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2424126#M64325</link>
      <description>&lt;P&gt;Hi Chili,&amp;nbsp;&lt;BR /&gt;Sorry for the confusion... The connection between 110,120 and 156 is something that is always the case but at the moment there is no data, which gives you that info, however I can create that if you wish?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;It is simply because the way the data is structured is that 110 and 120 contains i.e. a number of bonds and then when they are lend out they are moved from 110 and 120 to 150 such that the holding value is now present in 150, but for the overall view I need to "remove" the portfolio in the report that I am trying to create.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Please let me know if you need anything from me, thank you for the response yet again, I appreciate it much!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 11:54:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2424126#M64325</guid>
      <dc:creator>Solle</dc:creator>
      <dc:date>2022-03-29T11:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2424209#M64331</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;The connection between 110,120 and 156 is something that is always the case but at the moment there is no data, which gives you that info, however I can create that if you wish?&amp;nbsp;&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;Somewhere in the data, we have to know that, so if you can create a small sample with that, then yes please. (i am still confused about 156 as that seemed to appear as if by magic)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 12:33:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2424209#M64331</guid>
      <dc:creator>HotChilli</dc:creator>
      <dc:date>2022-03-29T12:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2424256#M64332</link>
      <description>&lt;P&gt;Hi Chili,&lt;BR /&gt;Sorry again! I mean 150 when i typed 156.. &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Do I need to provide you with a sample then?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 12:48:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2424256#M64332</guid>
      <dc:creator>Solle</dc:creator>
      <dc:date>2022-03-29T12:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2426364#M64448</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="371558" data-lia-user-login="Solle" class="lia-mention lia-mention-user"&gt;Solle&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try the following methods.&lt;/P&gt;
&lt;P&gt;Maesure:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;New Holding Value =
IF (
    SELECTEDVALUE ( 'Table'[PortfolioNbr] ) = 110,
    CALCULATE (
        SUM ( 'Table'[Holding Value] ),
        FILTER (
            ALL ( 'Table' ),
            [InstrumentSecurityID] = MAX ( 'Table'[InstrumentSecurityID] )
        )
    ),
    IF (
        SELECTEDVALUE ( 'Table'[PortfolioNbr] ) = 120,
        CALCULATE (
            SUM ( 'Table'[Holding Value] ),
            FILTER (
                ALL ( 'Table' ),
                [InstrumentSecurityID] = MAX ( 'Table'[InstrumentSecurityID] )
            )
        ),
        SELECTEDVALUE ( 'Table'[Holding Value] )
    )
)
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Is this the result you want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _Charlotte&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 09:27:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2426364#M64448</guid>
      <dc:creator>v-zhangti</dc:creator>
      <dc:date>2022-03-30T09:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2426395#M64453</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="332147" data-lia-user-login="v-zhangti" class="lia-mention lia-mention-user"&gt;v-zhangti&lt;/a&gt;&lt;BR /&gt;This is exactly what I want however it may seem as if it doesn't sum on the "AltPortfolioName" level and the "Aktivklasse" level when I have it in a Matrix, but when I unfold to a "InstrumentSecurityID" level it is working, beside that the AsOfDate filter does not seem to apply to this calculation? Do you know how to solve that?&lt;BR /&gt;&lt;BR /&gt;And thank you very much! This is super close to get me where I would like &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Solle&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 09:50:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2426395#M64453</guid>
      <dc:creator>Solle</dc:creator>
      <dc:date>2022-03-30T09:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2426434#M64456</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="371558" data-lia-user-login="Solle" class="lia-mention lia-mention-user"&gt;Solle&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Summation is also possible when there is no "InstrumentSecurityID" level in the matrix.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;What do you want to use the AsOfDate filter for? What kind of result will be output? It is better to show it with a picture.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _Charlotte&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 10:02:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2426434#M64456</guid>
      <dc:creator>v-zhangti</dc:creator>
      <dc:date>2022-03-30T10:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2426461#M64460</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="332147" data-lia-user-login="v-zhangti" class="lia-mention lia-mention-user"&gt;v-zhangti&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have just added the image below. The AsOfDate filter is used to swap between months as it is a monthly report that I am creating. Please see the slicer that I am using to select dates. As you see below there is no sum value for "NewHoldingValue"&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have the following applied to my table&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Please let me know if anything else is required?&lt;BR /&gt;&lt;BR /&gt;Thank you for the fast reply!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 10:12:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2426461#M64460</guid>
      <dc:creator>Solle</dc:creator>
      <dc:date>2022-03-30T10:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2431195#M64705</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="371558" data-lia-user-login="Solle" class="lia-mention lia-mention-user"&gt;Solle&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data you provided earlier did not mention dates to correlate the date slicer with the results I provided. What kind of dates do you have in your original table?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 06:59:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2431195#M64705</guid>
      <dc:creator>v-zhangti</dc:creator>
      <dc:date>2022-04-01T06:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2431205#M64707</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="332147" data-lia-user-login="v-zhangti" class="lia-mention lia-mention-user"&gt;v-zhangti&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Every month a new end of month date appears, so currently I have the following&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;However as the months go by there will be i.e. 31. March 2022 etc. Below is how it looks in the data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Sorry for not mentioning the date, I didnt think that, that had an impact on the results, as I am fairly new and is self-taught from the internet.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Best Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 07:06:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2431205#M64707</guid>
      <dc:creator>Solle</dc:creator>
      <dc:date>2022-04-01T07:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2431214#M64708</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="371558" data-lia-user-login="Solle" class="lia-mention lia-mention-user"&gt;Solle&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does your date look like in relation to Holding Value? Or does the date have a relationship to other fields? The first time you provided data, was it for one of your months?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 07:12:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2431214#M64708</guid>
      <dc:creator>v-zhangti</dc:creator>
      <dc:date>2022-04-01T07:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2431285#M64711</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="332147" data-lia-user-login="v-zhangti" class="lia-mention lia-mention-user"&gt;v-zhangti&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The date field is applied across all of the fields, meaning that you have date in a column where it is present - I am working with a very large data set, so everything is from the same source and everything have a date.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The first time I presented data I just showed some test data, as I cannot post the real data. But what I am working with is Portfolios in which there are some InstrumentSecurityID's then on a monthly basis I receive an output file which contains new information as the market has developed during the month. I am creating this report to quickly do a performance report, so yes there is a relation to Holding Value and the relation is like:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;AsOfDate&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Aktivklasse&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;AltPortfolioName&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;PortfolioNbr&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;InstrumentSecurityId&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Holding Value&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;31-01-2022&lt;/TD&gt;&lt;TD&gt;Repo&lt;/TD&gt;&lt;TD&gt;Repo&lt;/TD&gt;&lt;TD&gt;150&lt;/TD&gt;&lt;TD&gt;US000x0000&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;31-01-2022&lt;/TD&gt;&lt;TD&gt;Bonds&lt;/TD&gt;&lt;TD&gt;Bonds US&lt;/TD&gt;&lt;TD&gt;110&lt;/TD&gt;&lt;TD&gt;US000x0000&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;28-02-2022&lt;/TD&gt;&lt;TD&gt;Repo&lt;/TD&gt;&lt;TD&gt;Repo&lt;/TD&gt;&lt;TD&gt;150&lt;/TD&gt;&lt;TD&gt;US000x0000&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;28-02-2022&lt;/TD&gt;&lt;TD&gt;Bonds&lt;/TD&gt;&lt;TD&gt;Bonds US&lt;/TD&gt;&lt;TD&gt;110&lt;/TD&gt;&lt;TD&gt;US000x0000&lt;/TD&gt;&lt;TD&gt;300&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;An Example only involving Portfolio 110 with AsOfDate = 31-01-2022, but it is the same for 120 as it should be summed with 150 as well on a InstrumentSecurityID level.&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;So what I want is to have a slicer selecting the data and then the following table which sums depending on the date selected by the slicer:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;AsOfDate&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Aktivklasse&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;AltPortfolioName&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;PortfolioNbr&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;InstrumentSecurityId&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Holding Value&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Selected by Slicer (in this example 31-01-2022)&lt;/TD&gt;&lt;TD&gt;Bonds&lt;/TD&gt;&lt;TD&gt;Bonds US&lt;/TD&gt;&lt;TD&gt;110&lt;/TD&gt;&lt;TD&gt;US000x0000&lt;/TD&gt;&lt;TD&gt;100 + 50 = 150&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Please let me know if you need some furhter explanation and please be aware that the same InstrumentSecurityID can be present in other portfolios and the holding values from these shouldn't be included in the above.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 07:43:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2431285#M64711</guid>
      <dc:creator>Solle</dc:creator>
      <dc:date>2022-04-01T07:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Subtracting two rows based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2431391#M64720</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="371558" data-lia-user-login="Solle" class="lia-mention lia-mention-user"&gt;Solle&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is simple to add date specific filtering to the original formula.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;New Holding Value = 
IF (
    SELECTEDVALUE ( 'Table'[PortfolioNbr] ) = 110,
    CALCULATE (
        SUM ( 'Table'[Holding Value] ),
        FILTER (
            ALL ( 'Table' ),
            [InstrumentSecurityID] = MAX ( 'Table'[InstrumentSecurityID] )&amp;amp;&amp;amp;[AsOfDate]=SELECTEDVALUE('Table'[AsOfDate])
        )
    ),
    IF (
        SELECTEDVALUE ( 'Table'[PortfolioNbr] ) = 120,
        CALCULATE (
            SUM ( 'Table'[Holding Value] ),
            FILTER (
                ALL ( 'Table' ),
                [InstrumentSecurityID] = MAX ( 'Table'[InstrumentSecurityID] )&amp;amp;&amp;amp;[AsOfDate]=SELECTEDVALUE('Table'[AsOfDate])
            )
        ),
        SELECTEDVALUE ( 'Table'[Holding Value] )
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Did this result meet your expectations?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _Charlotte&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 08:26:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subtracting-two-rows-based-on-conditions/m-p/2431391#M64720</guid>
      <dc:creator>v-zhangti</dc:creator>
      <dc:date>2022-04-01T08:26:32Z</dc:date>
    </item>
  </channel>
</rss>

