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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register 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
Anonymous
Not applicable

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
PBIApril_Carousel

Power BI Monthly Update - April 2025

Check out the April 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.