Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
I need to use directquery to use parameter in slicer,
but my sql query is success in SQL SERVER but happen error when using direct query,
I have try to use -->select * from (.......my program......) as SourceQuery
still show error
"Microsoft SQL: Incorrect syntax near keyword 'declare'.
Incorrect syntax near ')'. "
I have so idea:(
I have the solution!
Convert your stored procedure to function that returns a table. It works!
Something like this:
create or alter function dbo.my_function()
returns @my_data table
(
Field1 varchar(20),
Field2 int,
Field3 int
)
as
begin
declare @test int
set @test = 1
insert into @my_data
select [Field1, Field2, Field3]
from [your table]
where Field3 = @test
return
end
@Lily36876 , You have to use select here. declare etc is not supported.
SP is supported, But not sure that can work direct query
thx For reply,that meas I can't use any declare in DQ?
| User | Count |
|---|---|
| 50 | |
| 36 | |
| 29 | |
| 18 | |
| 17 |
| User | Count |
|---|---|
| 66 | |
| 58 | |
| 39 | |
| 21 | |
| 20 |