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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Parameter error using DECLARE

i'm coming from an SSRS background. I'm mimicking a report we have in SSRS. i dont want to use a connector as we will be using the Power BI version from now on if we can get this working.

 

I've connected using a SQL statement and have a parameter called @Workspace and trying to add this dataset called @Location and this code below would do the work (this is a dataset i have on SSRS).

 

I tried using DECLARE but getting errors.

Any help appreciated 

 

IF @Workspace <> -1
BEGIN
SELECT
	Id, Name, WorkspaceId, SortGroup 
FROM 
	dbo.vw_pl_Locations
WHERE 
	Id = -1 OR
	(WorkspaceId = @Workspace AND
	Id <> @Workspace)
END

IF @Workspace = -1
BEGIN
SELECT
	Id, Name, WorkspaceId, SortGroup 
FROM 
	dbo.vw_pl_Locations
WHERE
	Id = -1 OR
	Id NOT IN (SELECT Id FROM dbo.vw_pl_Workspaces AS vpw)
END

 

 

 

 

bobbydave_0-1597922609247.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , I doubt you van give parameters like this

refer

https://www.biinsight.com/power-bi-desktop-query-parameters-part-1/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , I doubt you van give parameters like this

refer

https://www.biinsight.com/power-bi-desktop-query-parameters-part-1/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Would you know a workaround?

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.