<?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 Calculate Exchange rate for every day in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2206062#M51914</link>
    <description>&lt;P&gt;Hello community! I need help in solving following problem&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have a table with currency exchange rate for every day, but in some cases fields with exchange rate in some days are empty.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use those exch. rates to calculate different currencies in specific days. But when cell of rate is empty we can't make calculation, so in that cases we need to take exchange rate from the closest day where cell have data. How can propery fill those empty cells by taking the closest filled cell of specific currency, where the date of filled cell is closest to empty one? How can I write such calculateble collum?&amp;nbsp;&lt;BR /&gt;&lt;A href="https://drive.google.com/file/d/18I7dM418G5t0bOwzlQM4N6HNjBDaIjbI/view?usp=sharing" target="_self"&gt;file exemple&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Nov 2021 15:01:00 GMT</pubDate>
    <dc:creator>DimaMD</dc:creator>
    <dc:date>2021-11-24T15:01:00Z</dc:date>
    <item>
      <title>Calculate Exchange rate for every day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2206062#M51914</link>
      <description>&lt;P&gt;Hello community! I need help in solving following problem&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have a table with currency exchange rate for every day, but in some cases fields with exchange rate in some days are empty.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use those exch. rates to calculate different currencies in specific days. But when cell of rate is empty we can't make calculation, so in that cases we need to take exchange rate from the closest day where cell have data. How can propery fill those empty cells by taking the closest filled cell of specific currency, where the date of filled cell is closest to empty one? How can I write such calculateble collum?&amp;nbsp;&lt;BR /&gt;&lt;A href="https://drive.google.com/file/d/18I7dM418G5t0bOwzlQM4N6HNjBDaIjbI/view?usp=sharing" target="_self"&gt;file exemple&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 15:01:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2206062#M51914</guid>
      <dc:creator>DimaMD</dc:creator>
      <dc:date>2021-11-24T15:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Exchange rate for every day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2206270#M51928</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="312820" data-lia-user-login="DimaMD" class="lia-mention lia-mention-user"&gt;DimaMD&lt;/a&gt; , the first select date the conversion &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example new column&lt;/P&gt;
&lt;P&gt;Var _1 = maxx(filter(Rate, Rate[Currency] = Cost[Currency] &amp;amp;&amp;amp; Rate[Date]&amp;lt;= Cost[Date]) , Rate[Date])&lt;BR /&gt;return &lt;BR /&gt;maxx(filter(Rate, Rate[Currency] = Cost[Currency] &amp;amp;&amp;amp; Rate[Date] =_1) , Rate[Date])&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 16:50:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2206270#M51928</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2021-11-24T16:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Exchange rate for every day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2206320#M51930</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="312820" data-lia-user-login="DimaMD" class="lia-mention lia-mention-user"&gt;DimaMD&lt;/a&gt;&amp;nbsp; can you try out this measure, seems to be working for me&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;m2 = 
VAR _1 =
    ADDCOLUMNS (
        Costs,
        "dt",
--grabs the date from Exchange Rate on Currency+Date Partition
            VAR _dateFromExchangeRate =     
                CALCULATE (
                    CALCULATE (
                        MAX ( 'Exchange rate'[Date] ),
                        TREATAS (
                            SUMMARIZE ( Costs, Costs[Date], Costs[Currency] ),
                            'Exchange rate'[Date],
                            'Exchange rate'[Currency]
                        )
                    )
                )
            RETURN
--if the dateFromExchangeRate is blank, grabs the immediately preceding
-- date from Exchange Rate that has valid Exchange Rate ~ LASTNONBLANK 'Exchange rate'[Date]
-- done on currency partition
-- if the dateFromExchangeRate is not blank returns dateFromExchangeRate
                IF (
                    _dateFromExchangeRate = BLANK (),    
                    MAXX (                               
                        FILTER (                         
                            'Exchange rate',             
                            'Exchange rate'[Currency] = EARLIER ( [Currency] )
                                &amp;amp;&amp;amp; 'Exchange rate'[Date] &amp;lt;= EARLIER ( [Date] )
                        ),
                        'Exchange rate'[Date]
                    ),
                    _dateFromExchangeRate
                )
    )
VAR _2 =
    ADDCOLUMNS (                                    
        _1,  
--looks up the 'Exchange rate'[Exchange rate] based on the date obtained in the previous step                                       
        "val",
            MAXX (
                FILTER (
                    'Exchange rate',
                    'Exchange rate'[Currency] = EARLIER ( [Currency] )
                        &amp;amp;&amp;amp; 'Exchange rate'[Date] = EARLIER ( [dt] )
                ),
                'Exchange rate'[Exchange rate]
            )
    )
RETURN
    SUMX(_2,[val]*[Costs])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above generates this&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you look at this block&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The mesaure grabbed 26.33 from 2021-10-29 and multiplied that&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;The pbix is attached&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;
&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>Wed, 24 Nov 2021 17:41:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2206320#M51930</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2021-11-24T17:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Exchange rate for every day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2206359#M51932</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="24978" data-lia-user-login="smpa01" class="lia-mention lia-mention-user"&gt;smpa01&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;it's something an incredible, measure works&lt;BR /&gt;I am very grateful to you for your help&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 17:51:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2206359#M51932</guid>
      <dc:creator>DimaMD</dc:creator>
      <dc:date>2021-11-24T17:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Exchange rate for every day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2207302#M51990</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="24978" data-lia-user-login="smpa01" class="lia-mention lia-mention-user"&gt;smpa01&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;The mesure works correctly and&amp;nbsp; helped me a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to make some more calculations, and for that purpose we need to make a collum which will display all cells in USD. We need to multiply mesure M2 with USD currency, so we made a collum with USD currency, but the problem is when we have a row in table, that displays EUR, PLN etc, the cell stays empty. We need to fill all empty cells, no matter what currency was in a row, with USD&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 08:30:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2207302#M51990</guid>
      <dc:creator>DimaMD</dc:creator>
      <dc:date>2021-11-25T08:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Exchange rate for every day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2207879#M52020</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="312820" data-lia-user-login="DimaMD" class="lia-mention lia-mention-user"&gt;DimaMD&lt;/a&gt;&amp;nbsp; Can you please create a new thread on this?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 14:21:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2207879#M52020</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2021-11-25T14:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Exchange rate for every day</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2208225#M52045</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="24978" data-lia-user-login="smpa01" class="lia-mention lia-mention-user"&gt;smpa01&lt;/a&gt; New post &lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day-quot-USD-quot/m-p/2208223#M52044" target="_self"&gt;here&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 18:14:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-Exchange-rate-for-every-day/m-p/2208225#M52045</guid>
      <dc:creator>DimaMD</dc:creator>
      <dc:date>2021-11-25T18:14:48Z</dc:date>
    </item>
  </channel>
</rss>

