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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
datobi
Frequent Visitor

Relationship with direct and intermediate tables

Hi,

I'm a newbie in Power Bi.

I have three tables:

  1. payment transactions with:
    • transaction date (9-Mar-23)
    • currency (USD)
    • amount
    • Other fields
  2. forex table
    • start of the month (1-Mar-23)
    • currency (USD)
    • rate (3.7)
  3. dynamic calendar
    • date (9-Mar-23)
    • start of the month (1-Mar-23)

 

I can't create a relationship between (payment transaction table to forex table using currency parameter) and (payment transaction table to calendar table to forex table using payment transaction date to calendar date and then calendar start of the month to forex start of the month ) 

 

I can do using a merge queries with (power query/editor) by creating a new column in payment transaction.

 

 
 

bi.jpg

 

Is this even possible? Or should I just get start of month in transaction table and then do a combine value?

 

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

I would use LOOKUPVALUE inside a measure, e.g.

Converted amount =
SUMX (
    'Payment_Authorization',
    VAR ExchRate =
        LOOKUPVALUE (
            'forex'[rate],
            'forex'[currency], 'Payment_Authorization'[currency],
            'forex'[period], RELATED ( 'Calendar'[Start of month] )
        )
    RETURN
        'Payment_Authorization'[Amount] * ExchRate
)

View solution in original post

3 REPLIES 3
datobi
Frequent Visitor

Thanks, it is working.

I noticed that doing the calculation is slower than adding merge queries, is it normal?

Yes, when doing a lookup like this across a large dataset it will be slower using a measure. If performance becomes a problem then you could use the LOOKUPVALUE code to instead add a calculated column to the payment authorization table. That would increase the amount of time taken to load and refresh the data, but users would never see that, and it would make the measure very quick.

johnt75
Super User
Super User

I would use LOOKUPVALUE inside a measure, e.g.

Converted amount =
SUMX (
    'Payment_Authorization',
    VAR ExchRate =
        LOOKUPVALUE (
            'forex'[rate],
            'forex'[currency], 'Payment_Authorization'[currency],
            'forex'[period], RELATED ( 'Calendar'[Start of month] )
        )
    RETURN
        'Payment_Authorization'[Amount] * ExchRate
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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