Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
if both the ZA and RE rows in Document Type column should be marked as match if the Text column of the ZA document has a number that exactly matches the field for the RE invoice Reference number column (Sample has been shared)in Bold
Scripts | Vendor | VendorName | CompanyCode | FiscalYear | DocumentType | DocumentDate | PostingKey | PostingDate | DocumentNumber | Reference | Amountindoccurr | Documentcurrency | Amountinlocalcurrency | LocalCurrency | Text | Netduedate |
S(87-100)-4 | 2003232794 | US28 | 2024 | ZA | 31-01-2024 | 31 | 24-02-2024 | 5500485682 | 34467685 | -141107.8 | USD | -141107.8 | USD | 14917 | 3/31/2024 | |
S(87-100)-4 | 2003232794 | US29 | 2024 | RE | 31-01-2024 | 31 | 15-03-2024 | 5100922084 | 14917 | -141107.8 | USD | -141107.8 | USD | 3/31/2024 | ||
S(25-60)-1 | 2003188715 | US01 | 2024 | RE | 04-10-2023 | 31 | 26-08-2024 | 5100195502 | 6727721V | -95.51 | USD | -95.51 | USD | 12/3/2023 | ||
S(25-60)-1 | 2004015722 | FISHER SCIENTIFIC | US01 | 2023 | RE | 04-10-2023 | 31 | 10-10-2023 | 5101073037 | 6727721V | -95.51 | USD | -95.51 | USD | 12/3/2023 | |
S(25-60)-1 | 2003871958 | CINTAS CORPORATION N | US05 | 2024 | RE | 03-07-2024 | 31 | 26-08-2024 | 5100721502 | 4197836999 | -125.37 | USD | -125.37 | USD | VR:Pay-as-billed | 9/1/2024 |
S(25-60)-1 | 2000029014 | CINTAS CORPORATION 100 | US05 | 2024 | RE | 03-07-2024 | 31 | 25-07-2024 | 5101400093 | 4197836999 | -125.37 | USD | -125.37 | USD | VR:Pay-as-billed | 9/1/2024 |
S(25-60)-1 | 2000028457 | ARAMARK UNIFORM AND CAREER APPAREL | US05 | 2024 | RE | 09-07-2024 | 31 | 26-08-2024 | 5100716002 | 5630471355 | -128.4 | USD | -128.4 | USD | VR:Pay-as-billed | 9/22/2024 |
S(25-60)-1 | 2004363146 | VESTIS GROUP, INC. | US05 | 2024 | RE | 09-07-2024 | 31 | 05-08-2024 | 5101306140 | 5630471355 | -128.4 | USD | -128.4 | USD | VR:Pay-as-billed | 9/22/2024 |
S(25-60)-1 | 2004235596 | G&G OUTFITTERS INC | US05 | 2024 | RE | 09-02-2024 | 31 | 26-08-2024 | 5100153099 | 242772 | -166.75 | USD | -166.75 | USD | 4/9/2024 | |
S(25-60)-1 | 2000011986 | G&G OUTFITTERS INC | US05 | 2024 | RE | 09-02-2024 | 31 | 16-02-2024 | 5100042734 | 242772 | -166.75 | USD | -166.75 | USD | 4/9/2024 | |
S(25-60)-1 | 2003871958 | CINTAS CORPORATION N | US01 | 2024 | RE | 02-01-2024 | 31 | 26-08-2024 | 5101837000 | 4178789859 | -205.94 | USD | -205.94 | USD | 3/2/2024 | |
S(25-60)-1 | 2000029014 | CINTAS CORPORATION 100 | US01 | 2024 | RE | 02-01-2024 | 31 | 06-08-2024 | 5100524740 | 4178789859 | -205.94 | USD | -205.94 | USD | 3/2/2024 | |
S(25-60)-1 | 2003871958 | CINTAS CORPORATION N | US01 | 2024 | RE | 16-01-2024 | 31 | 26-08-2024 | 5100062509 | 4180383750 | -209.39 | USD | -209.39 | USD | 3/16/2024 | |
S(25-60)-1 | 2000011956 | CINTAS CORPORATION NO 2 | US01 | 2024 | RE | 16-01-2024 | 31 | 02-08-2024 | 5100900524 | 4180383750 | -209.39 | USD | -209.39 | USD | 3/16/2024 | |
S(25-60)-1 | 2003871958 | CINTAS CORPORATION N | US01 | 2024 | RE | 30-01-2024 | 31 | 26-08-2024 | 5101864000 | 4181744364 | -216.43 | USD | -216.43 | USD | 3/30/2024 | |
S(25-60)-1 | 2000029014 | CINTAS CORPORATION 100 | US01 | 2024 | RE | 30-01-2024 | 31 | 06-08-2024 | 5101205512 | 4181744364 | -216.43 | USD | -216.43 | USD | 3/30/2024 | |
S(25-60)-2 | 2000014020 | NYSCO PRODUCTS LLC | US05 | 2024 | RE | 31-01-2022 | 21 | 26-08-2024 | 5100824002 | 0236725-IN | 91.4 | USD | 91.4 | USD | VR:Full Accrual | 4/1/2022 |
S(25-60)-2 | 2000014020 | NYSCO PRODUCTS LLC | US05 | 2024 | RE | 31-01-2022 | 31 | 14-06-2024 | 5101023545 | 0236725-IN | -91.4 | USD | -91.4 | USD | ||
S(25-60)-2 | 2000022228 | W W GRAINGER | US01 | 2024 | RE | 22-03-2023 | 21 | 26-08-2024 | 5100336511 | 9648709799 | 217.97 | USD | 217.97 | USD | VR:Pay-as-billed | 7/20/2023 |
S(25-60)-2 | 2000022228 | W W GRAINGER | US01 | 2024 | RE | 22-03-2023 | 31 | 10-05-2024 | 5101295014 | 9648709799 | -217.97 | USD | -217.97 | USD | VR:Pay-as-billed | 7/20/2023 |
S(25-60)-2 | 2000022228 | W W GRAINGER | US01 | 2024 | RE | 15-05-2023 | 21 | 26-08-2024 | 5101843000 | 9706842102 | 144.47 | USD | 144.47 | USD | VR:Pay-as-billed | 9/12/2023 |
Hi @KuntalSingh, try this:
Output
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("vZdNb9swDIb/itHTBtQ2SZH62M1Ik85Yawd2smFfh67bYUBOG3rYv58kN43tOWnQpguCwJRh+dHLVxTz+fNZ+8qaFAFep3x2fkYAihQZFwL/Xbdk4zCFgU+F/1GYAqb3IwrDXU6BtiMiAGxFWwq3mbXRVvxliowIJrNx1ovJEWSHJjyWK8zjfF/PjyB0O8JmPkmIkoJ6IPRzOSKw3HvlMXgTZCSp9mB4D4bWGpQtGOAIjHOE8LR6UE6nYPtc6Lx+QTltyBjC9wHESSa44xqGYQ2Uq27aKSgGFENhzkXZvp03STsr59WqXJSzAaXaS+nD3Yin9KooUOaklMoL5yRoPSurVdEms7pZ1k2xKusqqTpQGec5N/nAh2M1PVqnJqMzVmnnXEwsSRbxt4kexu+bN8ubP+nN7/Tbz83mx3c/5PIDWQcgB8jT6J7iSHhvUdODR/YTO/Uf4C1LeL5oiuuieZesq3JRN9dJUV0ks6KZe8cUy6W/uJpeiHs0C6ghZkG0AjaopKsHZDPur6MfTi6DaP86WGmFrMOj83ZVtsllU6+X50lZzbLjuCW3eU9+Bdqn4KWpyU/rAvXllzsvkr5M6vVqUa5W86YN7PvQ6bDkKAqiXYjDBo2kWmdGeuTDOO57d8gniM4+mxR1/6jwpF4Co/iUpMdUknFhpu0W2SMoWmUg7mRGY411VuJmJJDM9ewwiuM2P5D+4yrHY7B6YFwQYsMnR32KqiHZo05hbFTQJOAirPXvUEagg3OZcn3YQRxhUT/iVtF7aOuEjgYeauuivCfHfYq4Ch4TF63mrWktGvYlkiMd6oxVj3YYR1oFp3btv7xD36I3pCCdjpYerMBAAar62M7qZNnUF+vZqk2urvbUrIf2Mc4waVtL3B1pvp3xPZCkZciSw95ZMAj8wbC422yS4vb2193NJpawuInpJZi7Suubct13g0cVljFzOuAcRuE7jUf+E+z6IfngD9qirC7nzZ5iRfedt9orplJaMNxxmq0BZ7qTC03mdn3NKJw4acNpPtFfPpd52wHLwKtOuh0wQE5HkOP4RaHDXxw5KDRaVl09cAa0ZcJoYWTOeAc5Cqf7Sbpn/voX", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Scripts = _t, Vendor = _t, VendorName = _t, CompanyCode = _t, FiscalYear = _t, DocumentType = _t, DocumentDate = _t, PostingKey = _t, PostingDate = _t, DocumentNumber = _t, Reference = _t, Amountindoccurr = _t, Documentcurrency = _t, Amountinlocalcurrency = _t, LocalCurrency = _t, Text = _t, Netduedate = _t]),
ZA_Text = List.Buffer(Table.SelectRows(Source, each ([DocumentType] = "ZA"))[Text]),
RE_Reference = List.Buffer(Table.SelectRows(Source, each ([DocumentType] = "RE"))[Reference]),
StepBack = Source,
Ad_Check = Table.AddColumn(StepBack, "Check", each
if [DocumentType] = "ZA" then
if List.Contains(RE_Reference, [Text]) then "match" else null else
if List.Contains(ZA_Text, [Reference]) then "match" else null, type text)
in
Ad_Check
Thanks for prompt reply!
took much time to load .it keeps on loading normal file size is 5MB but while loading it is more than 1.5 GB still keeps loading
NewStep=let ref=List.Buffer(YourTable[Reference]),txt=List.Buffer(YourTable[Text]) in Table.AddColumn(YourTable,"MatchMark",each if [DocumentType]="ZA" then List.Contains(ref,[Text]) else List.Contains(txt,[Reference]))
Thanks for relpy
It is not given the desired output ask is number in ZA type document have the same number in RE type document or vice versa as highlighte in black in given sample
Hi @KuntalSingh ,
Please try this M code:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("vZdNb9swDIb/itHTBtQ2SZH62M1Ik85Yawd2smFfh67bYUBOG3rYv58kN43tOWnQpguCwJRh+dHLVxTz+fNZ+8qaFAFep3x2fkYAihQZFwL/Xbdk4zCFgU+F/1GYAqb3IwrDXU6BtiMiAGxFWwq3mbXRVvxliowIJrNx1ovJEWSHJjyWK8zjfF/PjyB0O8JmPkmIkoJ6IPRzOSKw3HvlMXgTZCSp9mB4D4bWGpQtGOAIjHOE8LR6UE6nYPtc6Lx+QTltyBjC9wHESSa44xqGYQ2Uq27aKSgGFENhzkXZvp03STsr59WqXJSzAaXaS+nD3Yin9KooUOaklMoL5yRoPSurVdEms7pZ1k2xKusqqTpQGec5N/nAh2M1PVqnJqMzVmnnXEwsSRbxt4kexu+bN8ubP+nN7/Tbz83mx3c/5PIDWQcgB8jT6J7iSHhvUdODR/YTO/Uf4C1LeL5oiuuieZesq3JRN9dJUV0ks6KZe8cUy6W/uJpeiHs0C6ghZkG0AjaopKsHZDPur6MfTi6DaP86WGmFrMOj83ZVtsllU6+X50lZzbLjuCW3eU9+Bdqn4KWpyU/rAvXllzsvkr5M6vVqUa5W86YN7PvQ6bDkKAqiXYjDBo2kWmdGeuTDOO57d8gniM4+mxR1/6jwpF4Co/iUpMdUknFhpu0W2SMoWmUg7mRGY411VuJmJJDM9ewwiuM2P5D+4yrHY7B6YFwQYsMnR32KqiHZo05hbFTQJOAirPXvUEagg3OZcn3YQRxhUT/iVtF7aOuEjgYeauuivCfHfYq4Ch4TF63mrWktGvYlkiMd6oxVj3YYR1oFp3btv7xD36I3pCCdjpYerMBAAar62M7qZNnUF+vZqk2urvbUrIf2Mc4waVtL3B1pvp3xPZCkZciSw95ZMAj8wbC422yS4vb2193NJpawuInpJZi7Suubct13g0cVljFzOuAcRuE7jUf+E+z6IfngD9qirC7nzZ5iRfedt9orplJaMNxxmq0BZ7qTC03mdn3NKJw4acNpPtFfPpd52wHLwKtOuh0wQE5HkOP4RaHDXxw5KDRaVl09cAa0ZcJoYWTOeAc5Cqf7Sbpn/voX", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Scripts = _t, Vendor = _t, VendorName = _t, CompanyCode = _t, FiscalYear = _t, DocumentType = _t, DocumentDate = _t, PostingKey = _t, PostingDate = _t, DocumentNumber = _t, Reference = _t, Amountindoccurr = _t, Documentcurrency = _t, Amountinlocalcurrency = _t, LocalCurrency = _t, Text = _t, Netduedate = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Scripts", type text}, {"Vendor", Int64.Type}, {"VendorName", type text}, {"CompanyCode", type text}, {"FiscalYear", Int64.Type}, {"DocumentType", type text}, {"DocumentDate", type text}, {"PostingKey", Int64.Type}, {"PostingDate", type text}, {"DocumentNumber", Int64.Type}, {"Reference", type text}, {"Amountindoccurr", type number}, {"Documentcurrency", type text}, {"Amountinlocalcurrency", type number}, {"LocalCurrency", type text}, {"Text", type text}, {"Netduedate", type date}}),
MergedTables = Table.NestedJoin(#"Changed Type", {"Text"}, #"Changed Type", {"Reference"}, "NewColumn", JoinKind.FullOuter),
ExpandedTables = Table.ExpandTableColumn(MergedTables, "NewColumn", {"DocumentType", "Reference", "Text"}, {"DocumentType1", "Reference1", "Text1"}),
CustomColumn = Table.AddColumn(ExpandedTables, "MatchCheck", each if [DocumentType] = "ZA" and [DocumentType1] = "RE" and [Text] = [Reference1] then "Match"
else if [DocumentType1] = "ZA" and [DocumentType] = "RE" and [Text1] = [Reference] then "Match"
else null),
FinalTable = Table.RemoveColumns(CustomColumn,{"DocumentType1", "Reference1", "Text1"}),
#"Filtered Rows" = Table.SelectRows(FinalTable, each [Scripts] <> null),
#"Added Custom" = Table.AddColumn(#"Filtered Rows", "Custom", each let a=[Scripts],
b=[Vendor],
c=Table.RowCount(Table.SelectRows(#"FinalTable",each [Scripts]=a and [Vendor]=b and [MatchCheck]<>null))
in if c>0 then "Match" else null)
in
#"Added Custom"
Just put all of it into the Advanced Editor, and the final output is as below:
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Solution is correct, However data is keep on loading more than 9 hours and data size reaches 22 GB so it is not feasible.
Can you please help me to apply excel formula in power query
IF(LEFT(NewColumn,2)="RE",COUNTIFS(NewColumn,SUBSTITUTE(NewColumn,"RE","ZA")),IF(LEFT(NewColumn,2)="ZA",COUNTIFS(NewColumn,SUBSTITUTE(NewColumn,"ZA","RE")),""))
Can any one please help. Why size is increase from MB to 22 GB on last step
#"Added Custom" = Table.AddColumn(step, "Custom", each let a=[Reference],
b=[Text],
c=Table.RowCount(Table.SelectRows(#"FinalTable",each [Reference]=a and [Text]=b and [MatchCheck]<>null))
in if c>0 then "Match" else null)
in
#"Added Custom"
Complete code is
let
Source = Excel.Workbook(File.Contents("C:\Users\KUNTALSINGH\Box\PepsiCo - NA Process Session\ACL_Input.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Scripts", type text}, {"Vendor", Int64.Type}, {"VendorName", type text}, {"BusinessArea", type any}, {"CompanyCode", type text}, {"FiscalYear", Int64.Type}, {"DocumentType", type text}, {"DocumentDate", type date}, {"PostingKey", Int64.Type}, {"PostingDate", type date}, {"DocumentNumber", Int64.Type}, {"Reference", type text}, {"Amountindoccurr", type number}, {"DocumentCurrency", type text}, {"Amountinlocalcurr", type number}, {"LocalCurrency", type text}, {"ClearingDocument", Int64.Type}, {"ClearingDate", type text}, {"Text", type text}, {"NetDueDate", type text}}),
#"Filtered Rows2" = Table.SelectRows(#"Changed Type", each ([DocumentType] = "RE" or [DocumentType] = "ZA")),
MergedTables = Table.NestedJoin(#"Filtered Rows2", {"Text"}, #"Filtered Rows2", {"Reference"}, "NewColumn", JoinKind.FullOuter),
ExpandedTables = Table.ExpandTableColumn(MergedTables, "NewColumn", {"DocumentType", "Reference", "Text"}, {"DocumentType1", "Reference1", "Text1"}),
CustomColumn = Table.AddColumn(ExpandedTables, "MatchCheck", each if [DocumentType] = "ZA" and [DocumentType1] = "RE" and [Text] = [Reference1] then "Match"else if [DocumentType1] = "ZA" and [DocumentType] = "RE" and [Text1] = [Reference] then "Match"
else null),
#"FinalTable" = Table.RemoveColumns(CustomColumn,{"DocumentType1", "Reference1", "Text1"}),
#"Filtered Rows" = Table.SelectRows(#"FinalTable", each [Scripts] <> null),
step = Table.Buffer( #"Filtered Rows" ),
#"Added Custom" = Table.AddColumn(step, "Custom", each let a=[Reference],
b=[Text],
c=Table.RowCount(Table.SelectRows(#"FinalTable",each [Reference]=a and [Text]=b and [MatchCheck]<>null))
in if c>0 then "Match" else null)
in
#"Added Custom"
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
8 | |
8 | |
7 |
User | Count |
---|---|
14 | |
13 | |
9 | |
7 | |
6 |