Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
louagej
Regular Visitor

Transfer Query result in data table. Update or Create new row based on the primary key

Hi,

I'm using a odata service to load the latest changes from a table based on the SQL Timestamp.

We want to avoid that the query is loading each night millions of records.

So the result of my Query 1  can be a new or changed record and only returns a couple of hunded records each night.

 2017_12_07_ 002.png

After I this query is executed, I want to copy the rows to a data table in the report.

Based on the primary key, the second query should create a new row or update an existing row.

 

Any dea if that's possible?

Kind regards,

Job

Kind regards,
Job
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @louagej,

 

Maybe you can try to use 'Table.InsertRows' function to add custom row.

Table.InsertRows

 

Regards,

Xiaoxin Sheng

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @louagej,

 

>>So the result of my Query 1  can be a new or changed record and only returns a couple of hunded records each night.

You can try to use url convert to apply filter on result query.

URL Conventions (OData Version 3.0)

 

>>After I this query is executed, I want to copy the rows to a data table in the report.Based on the primary key, the second query should create a new row or update an existing row.

It is possible to create new row to lookup the update data, this created new column/row is a virtual column/row. Every time update/refreshed, these data will lost.

Good Ol' VLOOKUP - The Ultimate Guide to Lookups in Power BI

 

Regards,

Xiaoxin Sheng

hi Xiaoxin Sheng,

 

I'm already using the filtering on my oData set to only receive the changed or new records.

"http://<Servername>:<Serverport>/<Serverinstance>/OData/Company('CRONUS%20BELGI%C3%8B%20NV')/Items?$filter=SQL_Timestamp gt " & Number.ToText(Item_SQL_Timestamp).

 

The intention is that I can store this data in the report itself, so that it doesn't need to be loadthe complete dataset with every refresh.

 

My next SQL Timestamp for the next refresh would be the one I receive from my previous call:

 2017_12_08_ 001.png

 

Kind Regards,

Job

Kind regards,
Job
Anonymous
Not applicable

HI @louagej,

 

>>The intention is that I can store this data in the report itself, so that it doesn't need to be loadthe complete dataset with every refresh.

Yes, it is possible to look up value from another table and create a custom column to store them. For this column, it will be changed every time you refresh datasource.

 

Formula:

 

#"Added Custom" = Table.AddColumn(#"previous steps", "ColumnName", each Function.Invoke((id as any) => Table.SelectRows(#"QueryName",each [SearchColumn]= id),{[ParameterColumn]})[ResultColumn])

 

Sample:

#"Added Custom" = Table.AddColumn(#"previous steps", "SQL_TimeStamp", each Function.Invoke((No as any) => Table.SelectRows(Table2,each [No]= No),{[No]})[TimeStamp])

 

Regards,

Xiaoxin Sheng

Dear Xiaoxin Sheng,

Maybe my explanation was'nt very clear but I don't want to add an extra column.
I just need to insert a new row in case the primary key is new or update the row when it already exist.
All colums are already in the table.

I read on Power BI forum that it might be better to use direct query when we're dealing with large datasets.
Maybe I'm trying to use Power BI for something that it wasn't designed for.

Kind regards,
Job

Kind regards,
Job
Anonymous
Not applicable

Hi @louagej,

 

Maybe you can try to use 'Table.InsertRows' function to add custom row.

Table.InsertRows

 

Regards,

Xiaoxin Sheng

Hi,

 

Table.InsertRows was what I needed.

Thank you!

 

Kind Regards,

Job

Kind regards,
Job

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.