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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Power query

Screenshot_2023-06-19-07-45-49-18_87869c5c71fa0655e350912352595c23.jpg

Need an output of each invoices with their shipper name and invoice value in power query

 

2 REPLIES 2
ronrsnfld
Super User
Super User

Considering the lower portion of your report to be the relevant table

ronrsnfld_0-1769431103151.png

 

You can use this code pasted into the Advanced Editor

Please read the code comments for clarifications and explanation of the algorithm:

let

//Select the part of the invoice that represents the company entries
// change name accordingly in the next step
    Source = Excel.CurrentWorkbook(){[Name="AR_Ledger"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{
            {"Customer No./Name /#(lf) Document Number/Type", type text}, 
            {"Cus. Code /#(lf) Doc. Type", type any}, 
            {"Balance", Currency.Type}}),

//Group using the null values in the Balance column and the fourth and fifth arguments of the Table.Group function
//  first row will have the Customer No./Name
//  last row should have the total of the items

// But American Eagle has wrong total, possibly due to rounding error in your sample
//If you need to check for that, change the algorithm for Invoice Balance to sum all
//   except the last line
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Balance"}, {
        {"Customer No./Name", each [#"Customer No./Name /#(lf) Document Number/Type"]{0}, type text},
        {"Invoice Balance", each List.Last([Balance]), Currency.Type}
        }, GroupKind.Local,(x,y)=> Number.From(x[Balance]=null and y[Balance]=null)),
    
    #"Removed Columns" = Table.RemoveColumns(#"Grouped Rows",{"Balance"})
in
    #"Removed Columns"

 

To obtain this result:

ronrsnfld_2-1769431394919.png

 

 

 

 

pcoley
Super User
Super User

1st create a custom column:  if the column11(K) is null then take the value of the column1(A). 

2nd select the created custom column and fill down

3rd filter the column2(B) keeping only the cells needed: as seen you must filter the cells with "IN" value.

 

Rename the columns as needed:

Column1(A)--> DocNumber;

Column2(B)-->TypeOfDoc;

Custom-->Amount

pcoley_0-1769392294671.png

 

I hope this helps, if so, please mark as solution. Kudos are welcome

pcoley_1-1769392826908.png

 

.

If I helped solve your problem, mark this post as a solution.
Kudos are Welcome! | AI assisted for clarity of wording. |

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.