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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
AOD
Helper III
Helper III

Conditions in calculate function

Hi All, 

 

Need help in achiveing below 

 

I have 2 tables , table 1 have Product rate , and Table 2 has order with product and total amount ,

 

 

Table 1 
Product Product Rate 
ABC1000
DEF2000
XYZ3000

 

Table 2   
Order Product Total 
100001ABC10
100002DEF11
100003XYZ12
100004ABC13
100005DEF14
100006XYZ15

 

Would like to derive new column in table 2 as below highlighted, 

 

Table 2     
Order Product Total Rate ( which is derived as
( total /Product rate )*10
Calculation 
100001ABC100.1(10/1000)*10
100002DEF110.055(11/2000)*10
100003XYZ120.04(12/3000)*10
100004ABC130.13(13/1000)*10
100005DEF140.07(14/2000)*10
100006XYZ150.05(15/3000)*10

 

tried using if conditions in calculate but it doesnt work,

Please help. 

Thanks.

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @AOD 

 

I'm assuming that the rate table has distinct values for products, if this is not the case there is the need to make some changes to the calculation below, but you have two options:

Power Query

 

Add a new custom column with the following code:

 

([Total]/

(let Product = [Product] in Table.SelectRows(Rates, each [Product] = Product)){0}[Product Rate]) * 10

The important part is the let part of the syntax that picks up the value from the other table.

 

MFelix_1-1637002044267.png

 

 

Calculated column (needs to have a relationship between both tables)

RAte = DIVIDE(Orders[Total ], RELATED(Rates[Product Rate ])) * 10

MFelix_0-1637001708838.png

 

You can also use a calculated measure for this something similar to:

 

MFelix_2-1637002254491.png

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @AOD 

 

I'm assuming that the rate table has distinct values for products, if this is not the case there is the need to make some changes to the calculation below, but you have two options:

Power Query

 

Add a new custom column with the following code:

 

([Total]/

(let Product = [Product] in Table.SelectRows(Rates, each [Product] = Product)){0}[Product Rate]) * 10

The important part is the let part of the syntax that picks up the value from the other table.

 

MFelix_1-1637002044267.png

 

 

Calculated column (needs to have a relationship between both tables)

RAte = DIVIDE(Orders[Total ], RELATED(Rates[Product Rate ])) * 10

MFelix_0-1637001708838.png

 

You can also use a calculated measure for this something similar to:

 

MFelix_2-1637002254491.png

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.