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
Anonymous
Not applicable

parameters inside parameter of an sql query using DocumentDB

  Hi,
I am new to Power Bi, Could anyone help with the particular scenario I am facing.
I am connecting to CosmosDB using DocumentDB.Connect.
Following is the query used for connection.
let    Source = DocumentDB.Contents(ConnectionUrl, DatabaseName, CollectionName,
[Query = "SELECT * from logs where date > ' "&StartDate&" ' and date < ' "&EndDate&" ' ORDER BY date"])
StartDate and EndDate are the parameters being used. This query executes fine.
When I make the part of the query containing parameters into another parameter as follows.
 
Source = DocumentDB.Contents(ConnectionUrl, DatabaseName, CollectionName,
[Query = "SELECT * from logs where date ' "&DateRange&" ' ORDER BY date"])
where DateRange is a parameter defined in Power BI as follows.
 
DateRange =  > ' "&StartDate&" ' and date < ' "&EndDate&" '
When this query is executed, Power BI throws the following error.
DataSource.Error: Syntax error, incorrect syntax near 'DateRange'.
Details:
List
Can anyone please point me towards how the substitutions or de-referencing is done in Power Bi and,
is it possible to use parameters with in parameters.
Thank you.
0 REPLIES 0

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.