<?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: Divide by Constant Currency in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-by-Constant-Currency/m-p/1337017#M23786</link>
    <description>&lt;P&gt;I am doing the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Gross Sales 1 = 
var Sales = 
    CALCULATE(
        Totales[Gross Sales],
        Complete_Data[Version] in VALUES('Scenario 1'[Scenario 1])
        )

var Exchange = 
    CALCULATE(
    [TRM],
        FX[Version] in VALUES(Forex[Currency]),
        USERELATIONSHIP(Complete_Data[Month],FX[Month])
    )

return DIVIDE(Sales,Exchange)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-align-justify"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-align-justify"&gt;But apparently it is not calculating correclty:&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;The right one is the correct calculation with the old &amp;amp; inneficient code. Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 31 Aug 2020 20:22:41 GMT</pubDate>
    <dc:creator>juangomez</dc:creator>
    <dc:date>2020-08-31T20:22:41Z</dc:date>
    <item>
      <title>Divide by Constant Currency</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-by-Constant-Currency/m-p/1336729#M23778</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to optimice the following Dax measure:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SUMX (
    FILTER(Complete_DATA,Complete_Data[Version] in VALUES('Scenario 1'[Scenario 1])),
    DIVIDE (
        Totales[Gross Sales],
        SUMX(
            FILTER(
                FILTER(FX,FX[Version]=Forex[Selected Currency]),
                FX[Month]=Complete_DATA[Month]),
                FX[EUR to US]
            )
        )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 2 slicers, one to select an scenario (From the Complete_DATA table), and another to select the currency.&lt;/P&gt;&lt;P&gt;The idea is that the [Gross Sales] be divided by the corresponding currency (according to the scenario selected) and month independent of the "Date" as I could need 2020 sales in 2019 Exchange Rates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FX table has the following structure:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Month&lt;/TD&gt;&lt;TD&gt;Version&lt;/TD&gt;&lt;TD&gt;EUR to US&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01/01/2020&lt;/TD&gt;&lt;TD&gt;January&lt;/TD&gt;&lt;TD&gt;LC$&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01/01/2020&lt;/TD&gt;&lt;TD&gt;January&lt;/TD&gt;&lt;TD&gt;USD 2020&lt;/TD&gt;&lt;TD&gt;1.02&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01/01/2019&lt;/TD&gt;&lt;TD&gt;January&lt;/TD&gt;&lt;TD&gt;USD 2019&lt;/TD&gt;&lt;TD&gt;1.05&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;The previous DAX formula works, but is incredibly inefficient as it first goes to each of the Complete_DATA registry, divides the corresponding currency and then summarizes everything. With small data it doesn't matter but right now I have query updates of +3 minutes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the following with no success as Exchange is not calculating correctly:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Gross Sales 1 = 
var Sales = 
    CALCULATE(
    Totales[Gross Sales],
    Complete_Data[Version] in VALUES('Scenario 1'[Scenario 1])
    )

var Exchange = 
    CALCULATE(
    [TRM],
    FX[Version] in VALUES(Forex[Currency]),
    FX[Month] = SELECTEDVALUE(Calendario[Month])
    )

return DIVIDE(Sales,Exchange)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 16:47:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-by-Constant-Currency/m-p/1336729#M23778</guid>
      <dc:creator>juangomez</dc:creator>
      <dc:date>2020-08-31T16:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Divide by Constant Currency</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-by-Constant-Currency/m-p/1336786#M23781</link>
      <description>&lt;P&gt;Take your DAX query and analyze its query plan in DAX Studio.&amp;nbsp; Check the number of produced queries, the FE/SE ratio, and the overall number of records touched.&amp;nbsp; Then decide on how to change it.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 17:35:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-by-Constant-Currency/m-p/1336786#M23781</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2020-08-31T17:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: Divide by Constant Currency</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-by-Constant-Currency/m-p/1337017#M23786</link>
      <description>&lt;P&gt;I am doing the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Gross Sales 1 = 
var Sales = 
    CALCULATE(
        Totales[Gross Sales],
        Complete_Data[Version] in VALUES('Scenario 1'[Scenario 1])
        )

var Exchange = 
    CALCULATE(
    [TRM],
        FX[Version] in VALUES(Forex[Currency]),
        USERELATIONSHIP(Complete_Data[Month],FX[Month])
    )

return DIVIDE(Sales,Exchange)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-align-justify"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-align-justify"&gt;But apparently it is not calculating correclty:&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;The right one is the correct calculation with the old &amp;amp; inneficient code. Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2020 20:22:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Divide-by-Constant-Currency/m-p/1337017#M23786</guid>
      <dc:creator>juangomez</dc:creator>
      <dc:date>2020-08-31T20:22:41Z</dc:date>
    </item>
  </channel>
</rss>

