cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
snowstar
Frequent Visitor

Dynamic Parameter m Error with text value including -

Hello!

 

My Dynamic Parameter m is giving an error when the text value from a list of plain parameter has a hyphen (-) in it.

 

Like 312-34

 

Not sure why, I defined as text.

 

I get this error:

 

DataSource.Error: Microsoft SQL: Statement(s) could not be prepared.
Incorrect syntax near '-'.
Details:
DataSourceKind=SQL
DataSourcePath=mtlsql01;Reco_DEF
Message=Statement(s) could not be prepared.
Incorrect syntax near '-'.
ErrorCode=-2146232060
Number=8180
Class=16

 

Can anyone help?

 

I spent the whole day trying to figure it out.

 

Thanks!

 

2 ACCEPTED SOLUTIONS

Thanks for your help! (Not sure if I replied at the right spot)

 

This is the Query Code:

 

= Sql.Database("MTLSQL01", "Reco_DEF", [Query="SELECT *#(lf)FROM OPENQUERY ([MTLSQL01],#(lf)'EXEC Reco_DEF.dbo.DEF_Customer_Detail_NoDuplication_pbi " & ParamCustomer & ",
" & ParamCustomerLocation & " , " & Division & " ') " ])

 

This is the parameter code:

"2705-10" meta [IsParameterQuery=true, ExpressionIdentifier=CustomerLocation, Type="Text", IsParameterQueryRequired=true]

 

If I put the parameter in quotes in current value:  "2705-10" It works.

"""2705-10""" meta [IsParameterQuery=true, ExpressionIdentifier=CustomerLocation, Type="Text", IsParameterQueryRequired=true]

 

 

 

Thaks in advance.

 

 

View solution in original post

I fixed the issue.

After running profiler, I copied and pasted statement that was sent and ran it in sql.

It failed.

I added brackets to my parameter in sql and it worked.

I then added brackets in m:

[" & ParamCustomerLocation & "]

and it worked!

Maybe I need to do this because I am using OPENQUERY?

 

In any case thanks for your help watkinnc.

 

View solution in original post

5 REPLIES 5
watkinnc
Super User
Super User

So it looks like the parameter is named CustomerLocation; any reason why you use ParamCustomerLocation instead of just CustomerLocation?


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

I fixed the issue.

After running profiler, I copied and pasted statement that was sent and ran it in sql.

It failed.

I added brackets to my parameter in sql and it worked.

I then added brackets in m:

[" & ParamCustomerLocation & "]

and it worked!

Maybe I need to do this because I am using OPENQUERY?

 

In any case thanks for your help watkinnc.

 

Hi watkinnc,

 

THe parameter is ParamCustomerLocation and it takes the data from a list query called CustomerLocation.

watkinnc
Super User
Super User

Can we see some of your code, plus the parameter code?


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

Thanks for your help! (Not sure if I replied at the right spot)

 

This is the Query Code:

 

= Sql.Database("MTLSQL01", "Reco_DEF", [Query="SELECT *#(lf)FROM OPENQUERY ([MTLSQL01],#(lf)'EXEC Reco_DEF.dbo.DEF_Customer_Detail_NoDuplication_pbi " & ParamCustomer & ",
" & ParamCustomerLocation & " , " & Division & " ') " ])

 

This is the parameter code:

"2705-10" meta [IsParameterQuery=true, ExpressionIdentifier=CustomerLocation, Type="Text", IsParameterQueryRequired=true]

 

If I put the parameter in quotes in current value:  "2705-10" It works.

"""2705-10""" meta [IsParameterQuery=true, ExpressionIdentifier=CustomerLocation, Type="Text", IsParameterQueryRequired=true]

 

 

 

Thaks in advance.

 

 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors