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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
obc4758
Frequent Visitor

How can I add a where clause in my extend editor to my data base containing a parameter

I have the following:

 

   let Source = Sql.Database("Momo", "WorkCollaboration"), dbo_TimeReportOverview = Source{[Schema="dbo",Item="TimeReportOverview"]}[Data], #"Renamed Columns" = Table.RenameColumns(dbo_TimeReportOverview,{{"TimeReportSupContactPointValue", "Point Value"}}) in #"Renamed Columns"

 

obc4758_1-1616622930286.png

 

 

 

I have created a parameter SupplierContactIdParam  

I would like to say select * from Table TimeReportOverview where SupContactId = SupplierContactIdParam  

 

In the url to the report I would like to pass the value of the parameter using &rp:SupplierContactIdParam= 1

 

Tks for helping I'm totally new to this Christof

 

obc4758_0-1616622854253.png

 

1 ACCEPTED SOLUTION

HI @obc4758,

What connection mode are you worked? AFAIK, power bi does not allow you to invoke SP in directquery mode.
In addition, the issue seems related to your function structure, please remove the right " to fix the function usage:

let
    query_SP =
        "exec WorkCollaboration.dbo.SelectPersonalTimeReport @SupContactIdParam = "
        & Text.From(SupContactIdBiParam),
    Source =
        Sql.Database(
            "Momo",
            "WorkCollaboration",
            [Query = query_SP]
        )
in
    Source

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
obc4758
Frequent Visitor

I got a bit further. However on Power Query Result data are shown without an error. However when I exit it the power query it raises and error... 

 

My Query looks now like this

 

let
Quelle = Sql.Database("Momo", "WorkCollaboration", [Query="DECLARE @para AS Int=1;#(lf)Set @para = 1;#(lf)Select * from dbo.TimeReportOverview where SupContactId = @para"])
in
Quelle

obc4758_0-1616705001269.png

In addition I failed putting in my parameter 

 

I tried on the "set @para = 1" to use my parameter field with this syntax "set @para = &SupContactIdParam& without success. Could someone help me on the correct syntak please. Help would be very appreciated.

 

Dear All one further step after reading a lot...

 

So I had to create a stored procedure to create the working query

 

create Procedure SelectPersonalTimeReport @SupContactIdParam int
as exec WorkCollaboration.dbo.SelectPersonalTimeReport @SupContactIdParam = 1
Select * from dbo.TimeReportOverview where SupContactId = @SupContactIdParam;

 

The I created my report. Unfortuantely it does only work on import an not direct query. However at least ist works.

 

= Sql.Database("Momo", "WorkCollaboration", [Query="exec WorkCollaboration.dbo.SelectPersonalTimeReport @SupContactIdParam = 1"])

 

obc4758_0-1616786664232.png

Now I want to replace my value by a parameter value in ordert to publish out of my application the value via url to my report.

 

Sadly I failed to put in my Parameter. 

 

I tried three options

 

a) = Sql.Database("Momo", "WorkCollaboration", [Query="exec WorkCollaboration.dbo.SelectPersonalTimeReport @SupContactIdParam = " & SupContactIdBiParam & "])

 

obc4758_1-1616786912374.png

 

b) = Sql.Database("Momo", "WorkCollaboration", [Query="exec WorkCollaboration.dbo.SelectPersonalTimeReport @SupContactIdParam = " & Number.ToText(SupContactIdBiParam) & "])

 

obc4758_2-1616787037369.png

 

c) = Sql.Database("Momo", "WorkCollaboration", [Query="exec WorkCollaboration.dbo.SelectPersonalTimeReport @SupContactIdParam = " & Int16.From(SupContactIdBiParam) & "])

 

obc4758_3-1616787183840.png

 

 

I would be very pleased if someone could help. I guess it is a datatype problem.... my id in database is type int. My Parameter definition is type any

obc4758_0-1616787616175.png

Thanks for your advise how to manage this small last step

 

 

 

 

 

 

HI @obc4758,

What connection mode are you worked? AFAIK, power bi does not allow you to invoke SP in directquery mode.
In addition, the issue seems related to your function structure, please remove the right " to fix the function usage:

let
    query_SP =
        "exec WorkCollaboration.dbo.SelectPersonalTimeReport @SupContactIdParam = "
        & Text.From(SupContactIdBiParam),
    Source =
        Sql.Database(
            "Momo",
            "WorkCollaboration",
            [Query = query_SP]
        )
in
    Source

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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