Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
StefanKleinhans
New Member

Paginated Report - Parameter Issue - Invalid length parameter passed to the LEFT or SUBSTRING

Version:

StefanKleinhans_0-1731567581857.png


Simple Query - Not Main Query (Troubleshooting)

SELECT TOP 1
A.TenantId, A.CustID, A.OBNumber, A.SignalTime, A.MainArea
FROM tArchiveHistory(@Id) AS A
WHERE A.OBNumber = @OB
--WHERE A.OBNumber = '123456789'
--WHERE A.MainArea = @MainArea
AND A.OperatorTime IS NOT NULL

Remove @OB or hard code the works, Change it to A.MainArea = @MainArea Fails again
Change to diffrent table diffrent query and parameters. same thing happens, pass one parameter it works pass two it breaks

SQL Query Works - The Report builder Query Designer Works
Only when I run the report and the parameters needs to pass though does it brake.

Any expert out there that can advice me what the issue is

StefanKleinhans_1-1731567946229.png

StefanKleinhans_2-1731567966787.png

 

1 REPLY 1
v-jtian-msft
Community Support
Community Support

Hi,@StefanKleinhans .I am glad to help you.

It looks like you are having problems getting the dataset in Report Builder.

I think it may be an incorrect SQL statement or an incorrect parameter setting!
I noticed that you may be using CLR Table-Valued Functions
Because in your code the @Id parameter is after the table name (I think the incorrect use of the parameter is the most likely cause of your problem).
In your code

A.TenantId, A.CustID, A.OBNumber, A.SignalTime, A.MainArea
FROM tArchiveHistory(@Id) AS A
If tArchiveHistory is not a real, ordinary table, but a function table generated by a custom function run.
You need to ensure that the table function definition is correct
You need to check that the length of the function's argument is valid. If the length parameter passed to the LEFT function is negative or greater than the actual length of the string, it will result in an error. Regarding the parameter settings (types) in SQL Server and in Report Builder, you need to check.
I hope the link below will help you.

CLR Table-Valued Functions - SQL Server | Microsoft Learn
Paginated report parameters in Report Builder - Microsoft Report Builder & Power BI Report Builder |...
If your table is a real table, then you can refer to my test below

vjtianmsft_0-1731639458162.png

For Parameters, you need to additionally create separate DataSets for them and be careful about the type of Parameter set and whether multiple values are allowed or not
=@Par (Par is a single value)
in(@Par) (Par is now a list, containing multiple values)

vjtianmsft_1-1731639694779.pngvjtianmsft_2-1731639701509.png

vjtianmsft_3-1731639710019.png

vjtianmsft_5-1731639749452.png

 

vjtianmsft_4-1731639727964.png

Final Report DataSet

vjtianmsft_6-1731639782321.png

SELECT TOP 1
A.TenantId, A.CustID, A.OBNumber, A.SignalTime, A.MainArea
FROM tArchiveHistory AS A
WHERE A.OBNumber in (@OB)

AND A.OperatorTime IS NOT NULL
AND A.MainArea in (@MainArea)
AND A.CustID =@Id




--WHERE A.OBNumber = '123456789'
--WHERE A.MainArea in @MainArea

vjtianmsft_7-1731639807664.png

Here is my test data:

vjtianmsft_8-1731639824376.png

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.