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
Petter120
Helper I
Helper I

Parameter in MYSQL query is not working

Hi i have a MySQL query im trying to run from Power query editor and it usually work but this query has a parameter inside of it and its givning me an error:

SET @row_index := 1;

SET @row_index := -1;
SELECT DATUM,"FM" As Skift, Format(stddev(Duration),2) As STDEV, Format(avg(Duration),2) As Arimetric_Mean, (SELECT Format(AVG(subq.Duration),2) as median_value
FROM  (
    SELECT  s.DATUM, @row_index:=@row_index + 1 AS row_index, s.Duration
    FROM production_db.cykeltider_t as s
    WHERE s.LASTTID >= '2022-09-01 05:45:00' and s.LASTTID < '2022-09-01 15:00:00'  and s.OMRADE = "1022-08" 
    ORDER BY s.Duration) AS subq
  WHERE subq.row_index 
  IN (FLOOR(@row_index / 2) , CEIL(@row_index / 2))) as T

FROM production_db.cykeltider_t
WHERE LASTTID >= '2022-09-01 05:45:00' and LASTTID < '2022-09-01 15:00:00'  and OMRADE = "1022-08";

 

I am getting this error, an anyone assist me with this?

Petter120_0-1665616309143.png

DataSource.Error: ODBC: ERROR [42000] [MySQL][ODBC 8.0(w) Driver][mysqld-8.0.28]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT DATUM,"FM" As Skift, Duration, Duration
FROM production_db.cykeltider_t, ' at line 2
Information:
DataSourceKind=Odbc
DataSourcePath=dsn=MY_SQL
OdbcErrors=[Table]

 

Best regards 
Petter

3 REPLIES 3
ImkeF
Super User
Super User

Sorry, no further ideas from me here.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

ImkeF
Super User
Super User

Hi @Petter120 ,
could this actually be an issue with the double quotes? They act as escape signs in Power Query.
Couldn't you replace them with single quotes in your SQL-statement?

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

No that didnt work

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.

Top Solution Authors
Top Kudoed Authors