Forum Discussion
Select only one VAT for my table using Invoices XML
The duplication is happening because each invoice's Traslados node contains more than one tax row (one for IVA, one for IEPS), so when you expand Traslados to rows you get a row per tax and the invoice Total repeats - that's the "doubling TOTAL" and the 0 / IEPS rows you're seeing. You only want the IVA row. In the CFDI catalog, Attribute:Impuesto = 002 is IVA and 003 is IEPS.
The cleanest fix is to filter to IVA before you expand, so each invoice keeps exactly one row:
1) Don't expand Traslados to rows yet. Add a custom column that filters the nested tax table to IVA only:
= Table.SelectRows([Traslados], each [#"Attribute:Impuesto"] = "002")
2) Then expand only Attribute:Importe (and TasaOCuota if you need it) from that filtered column. Now each invoice contributes a single VAT amount and the Total no longer doubles.
If you've already expanded to rows, the quick fix is to filter the Attribute:Impuesto column to 002 and remove 003 (IEPS) - but filtering before expanding is better because it avoids the duplicated Total rows in the first place.
(Adjust the nested column name to match yours, and if your files store the tax name instead of the code, filter on "IVA" instead of "002".)