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
KF-Hornsby
Frequent Visitor

Divide a value by another value in a related table

Good afternoon, 

I'm trying to divide a sales value by an FX rate held in a different table.  I have a Sales Facts table with a many to one join to an FX Rates table (joined on currency code).  I need to calculate the sales in GBP.  Idealy, this would be as a calculated column as I need to re-use this elsewhere.

 

I've tried

Total Sales CY GBP = divide('Sales Facts'[Sales Value CY], related('FX Rates'[FXRate YTD]))

but I get the error 

KF-Hornsby_0-1619957271103.png

The relationship DOES exist.

 

KF-Hornsby_1-1619957437643.png

 

Any help greatly appreachiated.

 

Dave

1 ACCEPTED SOLUTION
KF-Hornsby
Frequent Visitor

It's a long time since I posted this so I think the answer was something along the lines of one of the tables being import and the other being direct query.  Once the whole model was set to import the issue stopped being a problem.

View solution in original post

7 REPLIES 7
KF-Hornsby
Frequent Visitor

It's a long time since I posted this so I think the answer was something along the lines of one of the tables being import and the other being direct query.  Once the whole model was set to import the issue stopped being a problem.

Rémi-Quentin
New Member

hi everyone,
i'm really interested in this topic as i seem to have the exact same issue with my measure.

i'm wondering if it has something to do with the main table (in the sumx) to be a direct query table ?

as i've tried it with other table that are in import mode and the error "this column either doesn't exist or ..." doesn't show up and it seems to calculate my measure.

i hope we'll soon have something to fix this 🙂

thanks,

Rémi

KF-Hornsby
Frequent Visitor

Is there anything special about this relationship what with it having the " <> " at either end?  Is it just representative of it joining two different data sources (a table imported/dual from a data flow and a direct query to a SQL server).

 

KF-Hornsby_3-1619974597800.png

 

Jihwan_Kim
Super User
Super User

Hi, @KF-Hornsby 

Please try something like below.

 

total sales CY GBP =
SUMX (
'Sales Facts',
'Sales Facts'[Sales Value CY] / RELATED ( 'FX Rates'[FXRate YTD] )
)

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


KF-Hornsby_1-1619973934003.png

 

Anonymous
Not applicable

Just a couple quick thoughts make sure data format are the same in both side.  You can also do a lookup function rather then related.  Lookup doesn't need a relationship between the 2 tables. 

example 

divide([sales] , lookup(fxrates[fxrate],fxrates[currcode],salesfact[currency code] )

KF-Hornsby_2-1619974289524.png

 

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.

Top Solution Authors