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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
nh27
Helper III
Helper III

Calculate discount using two tables

Hi fellow BI users, I need your help!


I am trying to create a measure called Discount which takes the discount value from a table "Discount_Lookup" and applies it to the row in "ZSALES" table.

 

There is a Many to One relationship right now from ZSALES to Discount_Lookup.

 

1.PNG

 

Discount = SUM(Zsales[Subtotal1])*SUM(Discount_Lookup[Discount])

 

The formula right now is taking SUM of total discount and applying that, but I want it row by row.

 

2.png

 

Total sum of discount is 0.82 which is what discount it is applying, but for above I want it row by row only. E.g. row 1 should be 2% of £28,224 and Discount column should be £564.48

 

Tried a few formula but hit a dead end, any ideas?

 

Thanks in advance 🙂

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

HI @nh27 

 

Can you share a sample of your data (both tables)?

BTW, try this:

 

Discount = SUM(Zsales[Subtotal1])*MAX(Discount_Lookup[Discount])

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!

 

View solution in original post

4 REPLIES 4
VahidDM
Super User
Super User

HI @nh27 

 

Can you share a sample of your data (both tables)?

BTW, try this:

 

Discount = SUM(Zsales[Subtotal1])*MAX(Discount_Lookup[Discount])

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!

 

Thank you so much, this seems to have done the trick! I'm confused as to how MAX has resolved this, would you be kind enough to explain why this worked?

Thanks in advance

It seems there are many rows for each item in your table and those rows have 2% in the discount column, when you use SUM, it will return the sum of the 2% (if there are 10 rows that will return 20%), but MAX will return just one of them which is 2%.

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!

YukiK
Impactful Individual
Impactful Individual

Use SUMX() instead of SUM(). Your measure will look like something like this:

 

Discount = SUMX(Zsales, Zsales[Subtotal1])*RELATED(Discount_Lookup[Discount]))

 

Please give it a thumbs up if this helps!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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