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
JimiH
Frequent Visitor

variable used in multiple queries

Hello

 

I have a value 'LocID' that appears in multiple tables in a SQL db I have.

At the moment I have to change the filter value multiple times in my quiries to get the

deired results.

 

I was hoping all I would need to do was setup a variable that I could change that would link to the different queries but

I cant figure that out.

 

Regards

 

Geoff

1 ACCEPTED SOLUTION
JimiH
Frequent Visitor

Think I have it

 

let
    Source = Sql.Database("eu-ske-sql-03", "ANL_ProAss"),
    dbo_OEE_FOR_BI = Source{[Schema="dbo",Item="OEE_FOR_BI"]}[Data],

     #"Sorted Rows" = Table.Sort(dbo_OEE_FOR_BI,{{"ShiftDay", Order.Descending}}),

    #"Filtered Rows" = Table.SelectRows(dbo_OEE_FOR_BI, each [LocId]=LineNumberPar)
in
    #"Filtered Rows"

View solution in original post

3 REPLIES 3
v-sihou-msft
Employee
Employee

@JimiH

 

In this scenario, you can create that LocID as query parameter.

 

Import the LocID as a dataset. Select that column and "Add as new query".

6.PNG

 

It will generate a List with this column.

 

81.PNG

 

Create a Parameter with this List. Select "Query" in Suggested Values.

 

89.PNG

 

Then you can use this parameter in your Power Query.

 

7.PNG

 

Regards,

Thank you

 

99% complete ,just failing as to where to insert the parameter in the power query

 

Parameter is 'LineNumberPar'

 

Power Query is

 

let
    Source = Sql.Database("server1", "ProApp"),
    dbo_OEE_FOR_BI = Source{[Schema="dbo",Item="OEE_FOR_BI"]}[Data],
    #"Sorted Rows" = Table.Sort(dbo_OEE_FOR_BI,{{"ShiftDay", Order.Descending}})
in
    #"Sorted Rows"

 

 

Also the parameter now enables the selection between values "1,2,3,4,5,6,7,8,9" is there a way to include all these values also?

 

So this would enable the user to select individual lines or include all lines?

 

Regards

 

Geoff

JimiH
Frequent Visitor

Think I have it

 

let
    Source = Sql.Database("eu-ske-sql-03", "ANL_ProAss"),
    dbo_OEE_FOR_BI = Source{[Schema="dbo",Item="OEE_FOR_BI"]}[Data],

     #"Sorted Rows" = Table.Sort(dbo_OEE_FOR_BI,{{"ShiftDay", Order.Descending}}),

    #"Filtered Rows" = Table.SelectRows(dbo_OEE_FOR_BI, each [LocId]=LineNumberPar)
in
    #"Filtered Rows"

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.