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
Anonymous
Not applicable

Allocate discount across invoice line items

Hi All 

 

I hope someone can help. I have a table from Xero with invoice data, each invoice is listed with seperate rows for each line item including the discount. I would like to be able to apportion the discount across each line based on the LineItem_LineAmount so that the true value of each line item can be seen.  Below is an example invoice where I have calculated the discount apportionment but which I am not able to do in Power Bi as a calculated column.  The discount should be the only line with a negative value.

 

If anyone could help it would be much appreciated

 

Thanks

Jack 

 

 

IdLineItem_DescriptionLineItem_LineAmountInvoiceNumberDiscount flag Discount calc 
6|9d11a032-bcd2-48bc-bde5-a62d5dc965edDiscount (custom discount)-59.14EB18237159.14
4|9d11a032-bcd2-48bc-bde5-a62d5dc965edStarter Fasteners - 10013.49EB182370-0.67444
1|9d11a032-bcd2-48bc-bde5-a62d5dc965ed10-40mm Riser - 10mm164.91EB182370-8.2448
5|9d11a032-bcd2-48bc-bde5-a62d5dc965ed Bearer - 50x50mm - 3.1m222.84EB182370-11.1411
2|9d11a032-bcd2-48bc-bde5-a62d5dc965ed Slate - 4m733.68EB182370-36.6809
3|9d11a032-bcd2-48bc-bde5-a62d5dc965ed6mm Fasteners - 10047.98EB182370-2.3988
3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi  @Anonymous ,

 

Is the discount column your excepted result? I cannot get the logic of that, Could you please share more details about that?

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Hi 

 

Yes the discount column is the expected result.

 

For each invoice the disount is removed (so that for the row with disount adding line item value and discount comes to zero), the dscount is then allocated across the line items (pro rated  by line item value) so that the total of the Disocunt column for any single invoice is zero but each line items row now has an allocated discount credit in that column.

 

I hope that makes sense?

 

Thanks 

Jack

 

 

Anonymous
Not applicable

 @v-frfei-msft 

 

Is there any more helpful information i can provide or a better way of laying it out? 

 

To try to summarise again for any group of rows in the table with the same invoice number, where there is a negative line item amount I want the calcaulted discount column to reverse it and apply the credit to the remaining lines in proportion to the line item amount.

 

I've also tried to simplify the original table.

 

Thanks 

Jack 

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.