<?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: Need to sum Sales, but need to flip RETURN transactions to negative before summing in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-sum-Sales-but-need-to-flip-RETURN-transactions-to/m-p/1249034#M20548</link>
    <description>&lt;LI-CODE lang="csharp"&gt;// The fact you can't create a calc column is not a show-stopper
// but the measure will be slower than it would be if you could
// create the column. One solution is this:

[Total Amount] =
var __returnPrefix = "sales ordlns-return"
var __prefixLength = len( __prefix )
return
SUMX(
	T,
	var __isReturn = 
		left(
			T[order_line_transaction_type_desc],
			__prefixLength
		) = __returnPrefix
	var __sign = not( __isReturn ) - __isReturn
	return
		__sign * T[commission_sales_usd_amount]
)&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 24 Jul 2020 16:35:46 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-07-24T16:35:46Z</dc:date>
    <item>
      <title>Need to sum Sales, but need to flip RETURN transactions to negative before summing</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-sum-Sales-but-need-to-flip-RETURN-transactions-to/m-p/1246598#M20459</link>
      <description>&lt;P&gt;For whatever reason, my company has our return sales values as a positive, so when you pull sales, your totals are high because they are the sum of sales plus the sum of returns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to sum "COMMISSION_SALES_USD_AMOUNT" below, but I need to multiply the last 5 lines of sales by -1 so that they decrease the total rather than increase it.&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the final values and total to look like the column below on the right.&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;Thanks in advance!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 01:15:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-sum-Sales-but-need-to-flip-RETURN-transactions-to/m-p/1246598#M20459</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-07-24T01:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need to sum Sales, but need to flip RETURN transactions to negative before summing</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-sum-Sales-but-need-to-flip-RETURN-transactions-to/m-p/1246820#M20460</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , Create a new column like&lt;/P&gt;
&lt;P&gt;net sales&amp;nbsp; = if([order_line_trns_desc] ="RETURN",-1*[COMMISSION_SALES_USD_AMOUNT],[COMMISSION_SALES_USD_AMOUNT])&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the exact return type text and correct column name&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or a measure like this&lt;/P&gt;
&lt;P&gt;net sales&amp;nbsp; = sumx(Table, if(Table[order_line_trns_desc] ="RETURN",-1*Table[COMMISSION_SALES_USD_AMOUNT],Table[COMMISSION_SALES_USD_AMOUNT]))&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 02:52:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-sum-Sales-but-need-to-flip-RETURN-transactions-to/m-p/1246820#M20460</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-07-24T02:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need to sum Sales, but need to flip RETURN transactions to negative before summing</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-sum-Sales-but-need-to-flip-RETURN-transactions-to/m-p/1246853#M20461</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Couple pitfalls, and thank you again for your assistance as I'm new to this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 - I'm using Direct Query, so I don't believe I can create a new column&lt;/P&gt;&lt;P&gt;2 - The Transaction Type Description is not just RETURN or ORDER, it is a string of text such as "SALES~ORDLNS~RETURN~1068~EXTERNAL~SELF SHIP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me write a measure similar to your SUMX measure that looks for the string "RETURN" rather than '...if = "RETURN"...'?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also I am not fully aware of the limitations of Direct Query vs Import, is Direct Query capable of writing that type of complicated measure or is it beyond limitations?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 03:01:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-sum-Sales-but-need-to-flip-RETURN-transactions-to/m-p/1246853#M20461</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-07-24T03:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need to sum Sales, but need to flip RETURN transactions to negative before summing</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-sum-Sales-but-need-to-flip-RETURN-transactions-to/m-p/1246884#M20465</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;- I'm thinking that you could use FIND or SEARCH to determine if your column contains RETURN and then flip it to negative that way.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 03:14:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-sum-Sales-but-need-to-flip-RETURN-transactions-to/m-p/1246884#M20465</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-07-24T03:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Need to sum Sales, but need to flip RETURN transactions to negative before summing</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-sum-Sales-but-need-to-flip-RETURN-transactions-to/m-p/1249034#M20548</link>
      <description>&lt;LI-CODE lang="csharp"&gt;// The fact you can't create a calc column is not a show-stopper
// but the measure will be slower than it would be if you could
// create the column. One solution is this:

[Total Amount] =
var __returnPrefix = "sales ordlns-return"
var __prefixLength = len( __prefix )
return
SUMX(
	T,
	var __isReturn = 
		left(
			T[order_line_transaction_type_desc],
			__prefixLength
		) = __returnPrefix
	var __sign = not( __isReturn ) - __isReturn
	return
		__sign * T[commission_sales_usd_amount]
)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 24 Jul 2020 16:35:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-to-sum-Sales-but-need-to-flip-RETURN-transactions-to/m-p/1249034#M20548</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-07-24T16:35:46Z</dc:date>
    </item>
  </channel>
</rss>

