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

Incremental refresh for MongoDB database

Will be happy if someone can help me 😔

i'm using MongoDB connected with PBI with BI connector to using ODBC DSN and every thing is working fine till now

recently i tried to setup incremental refresh by making Parameters <RangeStart> and <RangeEnd> then create filter for date/time columns filter-->betwwen and select in between dates. Once i close and Load the query the table gives error loading message "OLE DB or ODBC error: [DataSource.Error] ODBC: ERROR [HY000] [MySQL][ODBC 1.4(a) Driver][mysqld-5.7.12 mongosqld v2.14.5]This command is not supported in the prepared statement protocol yet.

Screenshot 2023-01-11 223251.jpg

Waiting my hero😀

25 REPLIES 25
lbendlin
Super User
Super User

You are supposed to replace your code, not append to it.

 

I used the [createdAt]  field as an example - modify as needed.

Hi Ibendlin!

Yes my target column is also [CreatedAt] same as you mentioned in your code and i replaced with this code but when i click Done it gives this error message

Screenshot 2023-01-17 213153.jpg

Screenshot 2023-01-17 213224.jpg

  

Good, making progress. What format does MongoDB expect for date or datetime fields?  Is "2023-01-17"  enough?

Screenshot 2023-01-17 220739.jpg

 it is date/time field firmat as shown in the photo

that's not what I meant. How is MongoDB expecting it to be formatted?  Can you show a sample SQL query?

Is it what you mean

Screenshot 2023-01-17 220739.jpg

Yes. Change your Power Query to 

 

DateTime.ToText(RangeStart,[Format="yyyy-MM-dd'T'HH:mm:ss'Z'"])

 

and the same for RangeEnd.

where can i add this statement exactly?

 

let
    Source = Odbc.Query("dsn=MongoDB", "select * from groupshops where [createdAt]>='" & DateTime.ToText(RangeStart,[Format="yyyy-MM-dd'T'HH:mm:ss'Z'"]) & "' and [createdAt]<'" & DateTime.ToText(RangeEnd,[Format="yyyy-MM-dd'T'HH:mm:ss'Z'"]) & "'")
in
    Source

I think i'm doing something wrong 

Screenshot 2023-01-18 001810.jpg

 

Can you get the SQL query to work with the same datetime values?  Maybe the expected format is different, or without single quotes etc.

I will contact database team and to try changing SQL format and will feedback you. thanks for your patience 😊

Anonymous
Not applicable

Hi @KareemMostafa12 ,

 

Is there any update on the issue?

 

   

                                                                                                                                                         

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

Still not solved i'm trying to find a solution with my database team to chage date formate 

lbendlin
Super User
Super User

Are you running a custom query or are you applying the RangeStart/RangeEnd filter later in the Power Query transforms?

I'm just applying RangeStart/RangeEnd filter later in the power query

May be that the query folding is not working properly for MongoDB.  Apply the parameters directly in the ODBC call.

 

NOTE:  one of the parameters must be inclusive and the other must be exclusive.  Otherwise you end up with gaps or overlaps between partitions.

Is it possible to show me how to apply the parameters directly in the ODBC call also can you inform me how can i make inclusive and exclusive parameters. Actually i'm not professional in PBI

Show a sanitized version of your Power Query code.  You can see the code by selecting  "Advanced Editor"

Screenshot 2023-01-15 221245.jpg

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.