Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
MarcF
Frequent Visitor

Best way to fix missing days for currency conversion API

Hi all,

 

I am looking for a best practice to fill missing days with my €/£ Quandl currency conversion API. The API feeds in currecny conversion for week days but returns null values during weekends and holdays. At the moment I have created a column which replaces the null values with the historical average rate:

 

Currency = IF(ISBLANK(calculate(sum(EURvsGBP[Value]))),average(EURvsGBP[Value]), calculate(sum(EURvsGBP[Value])))

 

Is there any better way of doing this? Ideally I would want a) the average to be weekly based, or b) replace the null values with the previous non-null.

 

Thank you.

1 ACCEPTED SOLUTION
Eric_Zhang
Employee
Employee

@MarcF

 

Supposing the dataset is as below.

 

Capture.PNG

 

Check a measure as

 

Currency = 
VAR lastNoBlankValDate =
    MAXX (
        FILTER (
            ALL ( EURvsGBP ),
            EURvsGBP[DATE] <= MAX ( EURvsGBP[DATE] )
                && EURvsGBP[VALUE] <> BLANK ()
        ),
        EURvsGBP[DATE]
    )
RETURN
    CALCULATE (
        SUM ( EURvsGBP[VALUE] ),
        FILTER ( ALL ( EURvsGBP ), EURvsGBP[DATE] = lastNoBlankValDate )
    )

 Capture.PNG

 

 

Regarding week-based, check if Week-Based Time Intelligence in DAX helps.

View solution in original post

4 REPLIES 4
Eric_Zhang
Employee
Employee

@MarcF

 

Supposing the dataset is as below.

 

Capture.PNG

 

Check a measure as

 

Currency = 
VAR lastNoBlankValDate =
    MAXX (
        FILTER (
            ALL ( EURvsGBP ),
            EURvsGBP[DATE] <= MAX ( EURvsGBP[DATE] )
                && EURvsGBP[VALUE] <> BLANK ()
        ),
        EURvsGBP[DATE]
    )
RETURN
    CALCULATE (
        SUM ( EURvsGBP[VALUE] ),
        FILTER ( ALL ( EURvsGBP ), EURvsGBP[DATE] = lastNoBlankValDate )
    )

 Capture.PNG

 

 

Regarding week-based, check if Week-Based Time Intelligence in DAX helps.

@Eric_Zhang,

 

How can this be achieved in a calculated column?

 

The measure is working but I am trying to create a calculated column to fill the missing values.

 

Any help will be appreciated.

@Eric_Zhang,

Had a similar problem and your solution helped solve it.

Great work.

Thanks, that works just great! I was wondering now what is the best database modelling practice for currency conversion data. At the moment I have three tables linked by 'Date':

 

CurrencyTable --- DateTable --- Sales

 

I have created a currency column in the DataTable with the exchange rate for the missing dates (as the CurrencyTable has no dates for weekends and bank holidays) and call it back in the sales table through a lookup. Is there a better way to do this?

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.