How to do it…

We will now generate the end dates for each currency exchange rate:

  1. Load the following script to generate the RateEndDate for each exchange rate:
ExchangeRate: 
LOAD 
FromCurrency, 
ExchangeRate, 
Date (RateStartDate) AS RateStartDate, 
If (FromCurrency=Peek (FromCurrency), Date (Peek 
(RateStartDate)-1), Today ()) AS RateEndDate RESIDENT ExchangeRatetemp ORDER BY FromCurrency, RateStartDate DESC; DROP TABLE ExchangeRatetemp;
  1. Go to the App overview window and open a new sheet.
  2. Enter the Edit mode by clicking on .
  3. Drag the Table object on to the screen and add all the four dimensions to it. Promote RateStartDate to the top of the sorting order and set the sort order as numeric Ascending.
  4. The result would be as follows:
  1. As we can see, every record for a currency now has a rate end date.
  2. We will now use the RateStartDate and RateEndDate fields as our base dates for the exchange rate calendar.
  3. Now, copy and paste the following script after the DROP TABLE ExchangeRatetemp statement:
//------------------------------------------------- 
// Generate calendar dates 
//------------------------------------------------- 
 
LET ExStartDate = Num(Peek('RateStartDate', -1, 
ExchangeRate)); LET ExEndDate = Num(Peek('RateEndDate', 0, ExchangeRate)); ExchangeRateCalendar: LOAD Date($(ExStartDate) + RecNo() - 1) AS ExchangeRateDate AUTOGENERATE ($(ExEndDate) - $( ExStartDate) + 1); //-------------------------------------------------- // INTERVAL MATCH JOIN the month records to the calendar
// table //-------------------------------------------------- LEFT JOIN (ExchangeRateCalendar) INTERVALMATCH (ExchangeRateDate) LOAD RateStartDate, RateEndDate RESIDENT ExchangeRate; LEFT JOIN (ExchangeRateCalendar) LOAD * RESIDENT ExchangeRate; DROP TABLE ExchangeRate; ExchangeRate: LOAD FromCurrency, ExchangeRateDate, ExchangeRate RESIDENT ExchangeRateCalendar; DROP TABLE ExchangeRateCalendar;
  1. Again, create a Table object on the sheet and get all the dimensions from the ExchangeRate table.
  1. We will have exchange rates for each of the missing dates as well, as shown in the following screenshot:
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset