cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hussain_onmodus
New Member

ODBC Data source - Date Parameter not working

Hi, 

I have taken data from ODBC Bigquery DSN and trying to add a query over it. The query works fine when I give it fixed date values for the date range. 

However It doesn't work when I am trying to add a Date Parameter to it to dynamically change the date range. 

Here is how I have defined my date paramater. 

and here is the query for the odbc data source:

 

Odbc.Query("dsn=Google BigQuery", "#(lf)SELECT#(lf)    DISTINCT #(lf)    client_id,#(lf)    domain,#(lf)    company,    #(lf)FROM#(lf)  `bq_project.bq_dataset.bq_table` #(lf)WHERE#(lf)   FORMAT_DATE('%d/%m/%Y', date)  <= '" &endDate& "'#(lf)    and source != 'direct'#(lf) and  not REGEXP_CONTAINS(source, 'paypal' )#(lf)    AND DATE >= '2020-12-16'")

 

 
It returns Expression.Error: We cannot apply operator & to types Text and Date.

Please note that the datatype of date column in the datasource is date and not text. 

Not sure what am I doing wrong here. Please help me with it. 

1 ACCEPTED SOLUTION
CNENFRNL
Super User
Super User

@hussain_onmodus , the issue has nothing to do with the dataset; but only with your M code. It seems the data type of endDate is date. You might want to try to subsitute your orignal code &endDate& with & Date.ToText(endDate, "ddMMyyyy") &


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

1 REPLY 1
CNENFRNL
Super User
Super User

@hussain_onmodus , the issue has nothing to do with the dataset; but only with your M code. It seems the data type of endDate is date. You might want to try to subsitute your orignal code &endDate& with & Date.ToText(endDate, "ddMMyyyy") &


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through June10th!

Power BI Dev Camp Session 22 without aka link and time 768x460.jpg

Check it Out!

Watch Session 22 Ted's Dev Camp along with past sessions!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!

Top Kudoed Authors