Forum Discussion
Need Help with M Code
First of all, thank you all very much!
I will be more specific about the problem itself. I apologize for the unclear request.
I have these two tables in BI:
1st - Table Total
| Final Status | Count | Update_Date |
| Completed | 36800 | 02/21/2025 |
2nd - Table Evolution
| Final Status | Count | Update_Date |
| Completed | 36800 | 02/21/2025 |
| Completed | 38123 | 02/22/2025 |
In the first table there will always be only one row that will be updated frequently, with the fields "update date" and "count" being changed.
According to verification, new rows will be inserted in the second table each time the first table is updated. This will increase over time and accumulate the update values.
I tried in some ways to perform the conditional check and insert the new row using the Table.InsertRows function, but Microsoft Power BI always issues error messages. I tried more than one code.
I believe you can do this with incremental refresh. See https://learn.microsoft.com/en-us/power-bi/connect-data/incremental-refresh-overview
I think doing the below will meet your needs.
1) Set up a third table that references Table Total where all new rows will accumulate/increment on this third table.
(However you have been maintaining Table Evolution, you would keep that as a static snapshot going forward)
2) Set up filters to dictate whether the current (at time of refresh) Table Total row should be added (including the check against snapshot of Table Evolution + this new incrementing table).
3) Set up RangeStart and RangeEnd datetime parameters and have it filter the incremental table as described in link above.
4) Now after loading everything, if you set up RangeStart and RangeEnd correctly, you'll be able to turn on incremental refresh for the new table.
This only works if you just need to check Table Total once a day.
If you need to capture the temporary single row at multiple points a day, you would probably have to do something like set up a helper query per time when Table Total refreshes throughout the day and then have the incrementing table check them all. That's getting pretty out of hand, though (and won't work if Table Total updates at random times throughout day). I would probably rather start looking at other approaches - e.g. maybe using Power Automate to drop rows into a SharePoint list to then check all at once at the end of the day.