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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
HansDW
Regular Visitor

Calculate percentage between 2 values in 2 different tables (Query out of ERP)

Hello

We have query what gets all invoiced lines in a period and our standard sales price list.

 

Now i want to see per invoice line the discount vs the general price list.

 

General Pricelist
ArticlePrice
Article 110,6
Article 212
Article 35

 

Invoices
InvoicesArticleUnitPrice
1Article 1    10
1Article 3    11,5
1Article 2    4,8
2Article 3    4,9
2Article 2    11
3Article 1    9
3Article 3    4
10 REPLIES 10
Anonymous
Not applicable

Hi @HansDW ,

 

Any updates? Please feel free to ask.

 

Best Regards,
Eyelyn Qin

Anonymous
Not applicable

Hi @HansDW ,

 

To my knowledge, such error occurs when your [pricevar] is 0 or blank, which means it did not return correct values.

Eyelyn9_0-1654764455107.png

And since I didn't see [ItemCode] in your screenshot, I need more details to clarify your scenario.

Please kindly take a look at the blogs to know

How to Get Your Question Answered Quickly - Microsoft Power BI Community

How to provide sample data in the Power BI Forum - Microsoft Power BI Community

 

 

Best Regards,
Eyelyn Qin

Anonymous
Not applicable

Hi @HansDW ,

 

Please try:

Discount = 
var _price=CALCULATE(SUM('General Pricelist'[Price]),FILTER('Invoices',[Article]=MAX('General Pricelist'[Article])))
return (_price- SUM(Invoices[UnitPrice]))/_price

Eyelyn9_0-1654737494156.png

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi eyelyn

Much appreciated your help. But in my real data I get -Infinity as a result.

 

Discount% = VAR pricevar = Calculate(SUM(PricelistEUR[EurPrice]), Filter('FullSalesData',[ItemCode]=MAX(PricelistEUR[ItemCode]))) return (pricevar - SUM(FullSalesData[UnitPrice]))/pricevar

HansDW_0-1654759392582.png

 

 

Best regards

Hans

Anonymous
Not applicable

Hi @HansDW ,

 

Is there any update?

You could use the following syntax to create a measure:

% = SUM(Invoices[UnitPrice]) /  CALCULATE(SUM('General Pricelist'[Price]),FILTER('Invoices',[Article]=MAX('General Pricelist'[Article])))

Eyelyn9_0-1654584859812.png


Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks Eyelyn

 

But this is not the discount.

 

[Line 1] This is what 10 is of 10.60€. Should give 5.66%

 

Hans

 

rohit_singh
Solution Sage
Solution Sage

Hi @HansDW ,

Please try the steps below:

1) Load the following tables into the report view


Table 1 : General Pricelist

rohit_singh_0-1654183914358.png

Table 2 : Invoices

rohit_singh_1-1654183934171.png

 

2) Create relationship between the two tables using Article column as the key

rohit_singh_2-1654184617830.png

 

3) Add the below columns to the table view. You will now be able to see both general and discounted prices on the same row.

rohit_singh_3-1654184697586.png

 

Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

 

Hi Rohit_Sing

Step one and two was already OK, Adding the column as is, is not possible. Its a continious update out of OUR ERP.  I could add the pricing table to the invoice table due to aitchandak related solution. it's multiple in invoice table., So one in pricelist can have 100 different pricins in invoice.

 

amitchandak
Super User
Super User

@HansDW , if there is a relation between table 1 and table 2 (1 to Many) . then you can use related(table1[Price]) in a column or measure from table 2 as per need

 

refer 4 ways to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Relation was already setup. Added the relate collmn. Now trying to to the percentage calculation 😉 Will come back.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors