Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi, Guys!
I need to insert a new row into a table based on a conditional check of the highest date in this table with the Date field in another table.
The new row should only be inserted if the maximum Date in the table is greater than the Date in the other table (which is unique).
It would basically be an auto-increment of new rows as the values are different.
Hello @Pertemhru,
Could you please confirm if your query have been resolved? If they have, kindly mark the helpful response and accept it as the solution. This will assist other community members in resolving similar issues more efficiently.
Thank you.
Hi @Pertemhru,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.
Hi @Pertemhru,
Just wanted to confirm if you had the chance to review the information provided by @lbendlin and @MarkLaf. Should you have any further questions, please do not hesitate to contact us. If there response has addressed your query, kindly accept it as a solution and give a 'Kudos' to help other members find it easily.
Thank you.
try this approach (if it not clear, let me know to provide you an example)
Find the max date from the first table (MainTable).
Compare it with the date in the second table (ReferenceTable).
If the max date is greater, add a new row with the necessary values.
Append the new row (if needed) to the existing table.
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.
As noted, it's a little ambiguous as to what you want. What if there are multiple later dates in the other table? When you say "increment", do you really mean adding a single date, or do you mean adding all dates up to the latest in the other table? To give you an idea, I walked through a few different options.
Given the starting table that we plan to increment and the other table we want to check against...
Increment:
| Date | Column A | Column B |
| 1/1/2024 | a | 1 |
| 3/1/2024 | b | 2 |
| 6/1/2024 | c | 3 |
Check:
| Date | Column C | Column D |
| 1/1/2024 | a1 | 20 |
| 3/1/2024 | b1 | 30 |
| 6/1/2024 | c1 | 12 |
| 6/3/2024 | d1 | 10 |
| 6/10/2024 | e1 | 60 |
Here is some M that figures out potential different lists of dates you may want to consider the "increment" to add and converts them into Increment table rows (as a table) that you can easily add to Increment (i.e. with Table.Combine)
let
//A function that converts list of dates into same dates in Increment table schema.
//If input is an empty list, we just get an empty table as output.
DatesToIncrRows =
(dates as list) as table =>
Table.FromRecords(
List.Transform( dates, each [Date=_] ),
Value.Type( Increment ),
MissingField.UseNull
),
//Get max date from Increment.
MaxFromIncr = List.Max( Increment[Date] ),
//Get ALL dates in other table later than Increment max.
//Will be empty list if no later dates.
AllLaterFromCheck =
List.Select( Check[Date], each _ > MaxFromIncr ),
//Get max date out of dates later than Increment max.
//Will be null if AllLaterFromCheck is empty list {}.
MaxFromLater = List.Max( AllLaterFromCheck ),
//If a MaxFromLater exists, wrap in list to work with our function.
//Otherwise, return empty list {}.
MaxToList =
if MaxFromLater = null then {} else { MaxFromLater },
//Get all dates between Increment max (exclusive) and Check max (inclusive).
//Or return empty list if no later dates exist in Check.
AllBetweenIncrAndCheck =
if MaxFromLater = null then {} else List.Dates(
Date.AddDays( MaxFromIncr, 1 ),
Duration.Days( List.First(MaxToList) - MaxFromIncr ),
#duration(1,0,0,0)
),
//Sticking different options into a record for easy access.
//Use this in other queries with reference like: IncrementOptions[All Later Dates From Check].
Options = [
Only Latest Date In Check = DatesToIncrRows( MaxToList ),
All Later Dates From Check = DatesToIncrRows( AllLaterFromCheck ),
All Later Dates Between Check And Incr = DatesToIncrRows( AllBetweenIncrAndCheck )
]
in
Options
Output:
And to be clear, the idea would be to union the desired output with your original Increment using Table.Combine to get the final table. And note that Table.Combine( { Whatever Table, Empty Table } ) = Whatever Table - i.e. it handles the case where there are no later dates in Check. Example where the above query is called IncrementOptions:
= Table.Combine( { Increment, IncrementOptions[All Later Dates Between Check And Incr] } )
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.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...
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.
Power BI has no memory* .You need to manage your snapshots in the upstream system.
* Yes, there is the self referencing option but that has no safety net.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 8 | |
| 7 |