Solution
I have had the same problem, I am importing a folder with several excel files using PowerQery ... the problem occurs when I change the structure of the source files (number of columns).
As I understand it, Excel uses automatic grouping in dates within dynamic tables, this grouping generates indexes in the data model.
when you changes the column number in source files, Excel loses the date index position.
my solution was to create two separate queries in PQ
I handle dates, documents and articles, which represent my key fields
my first query uses only the date and the document, and I apply them distinct rows
So I import to the data model a table with unique documents and date, ins in that table where Excel will deposit the indices for the calculation of months, quarters and years
later I create the query with all the other fields (excluding the date field) and append it to the data model.
Already in the data model the relationship between both queries based on the document field is created
In dynamic tables I use the dates from the date query and the other fields from the other query. So no matter if I alter the structure of the source files, the dates and their indexes are respected
I hope I have been clear and can serve you