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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

Hi @louagej,

 

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

Table.InsertRows

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

6 REPLIES 6
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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

Hi @louagej,

 

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

Table.InsertRows

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi,

 

Table.InsertRows was what I needed.

Thank you!

 

Kind Regards,

Job

Kind regards,
Job

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.