Prepstellar

PL-300 · Get or connect to data

21 cards

Power Query Parameters

Swipe, scroll or use ← →
  1. Why parameters make a query reusable

    A Power Query parameter stores a value that a query can use. Its purpose is to separate a changeable input from the rest of the query design: the developer can replace the input without rewriting the complete query.

    Imagine a sales report backed by SQL Server. The SQL query already returns sales for one salesperson, but the developer needs to produce the same view for different members of the team. A parameter named SalesPerson can supply the selected salesperson value to the native query. The report logic stays in place while the value that controls the returned data changes.

    This is a developer-controlled form of a dynamic report. The selected parameter value determines which data the query returns, so one report can serve more than one purpose and reduce the need for separate copies of the report.

    1 / 21
  2. Why parameters make a query reusable

    Keep the value, the query, and the result conceptually separate.

    Part Role
    Parameter Holds a named, typed value such as SalesPerson.
    Source query References that parameter where it previously used a fixed value.
    Returned data Changes when the referenced parameter receives a different active value.

    In this single-value pattern, the report displays data for one selected salesperson at a time. Changing the active value lets the same query return another salesperson's data; it does not redesign the query.

    A parameter has no effect merely because it exists. If the source query still contains its original fixed salesperson value, changing the parameter cannot alter the result. The connection between the source expression and the parameter is therefore essential.

    2 / 21
  3. Quick check

    A developer wants one sales report to return a different salesperson without rebuilding its query. What makes that possible?

    1. AA second report with the same query and a different fixed value

      A copied report can contain another fixed value, but it does not make the original query reusable through a parameter.

    2. BA parameter that exists but is not referenced by the source query

      An unreferenced parameter is detached from the source expression, so changing it cannot change the query result.

    3. CA named parameter whose active value is referenced by the source query

      Right. The parameter separates the adjustable salesperson value from the query design, and the query reference makes the value affect the returned data.

    3 / 21

  4. Connect with the initial native query

    The workflow starts with a working SQL query. In Power BI Desktop, select Get data and connect to SQL Server. After entering the server details, use the SQL Server database window to submit the query:

    1. Expand Advanced options.
    2. Paste the query into the SQL statement box.
    3. Select OK to connect.

    When the connection succeeds, Power BI shows the data in a preview window. Inspect that preview to confirm that the initial query returns the expected data. Then select Edit to open the data in Power Query Editor.

    At this point, the query can still contain a fixed salesperson value. That is intentional: first establish that the connection and native SQL work; then create the parameter and bind it to the query.

    4 / 21
  5. Connect with the initial native query

    Each command has a distinct job in this opening sequence.

    Command What it does
    Get data Starts the SQL Server connection.
    Advanced options → SQL statement Supplies the native SQL query.
    Edit Opens the previewed data in Power Query Editor.
    Manage parameters → New parameter Comes next; it defines the adjustable value.

    Do not confuse the SQL statement box with parameter creation. Advanced options lets you submit the native query, but it does not define SalesPerson. Likewise, selecting Edit opens the query for preparation; it does not yet replace the fixed value.

    The useful mental model is connect, preview, edit. Only after the query is available in Power Query Editor do you create its named input and revise the source expression to use it.

    5 / 21
  6. Quick check

    You have a working salesperson SQL query and want to prepare it for parameterization. Which sequence gets it into Power Query Editor?

    1. ACreate SalesPerson first, then use Close and Apply to connect

      New parameter is created in Power Query Editor; Close and Apply returns to the report editor and does not establish this initial connection.

    2. BUse Get data, connect to SQL Server, paste the query, then Edit

      Right. This sequence establishes the SQL Server connection, submits the statement under Advanced options, previews the native query, and opens it in Power Query Editor.

    3. COpen Edit parameters, enter a server name, and select Apply changes

      Edit parameters changes an existing parameter value; it does not connect to SQL Server or submit the initial query.

    6 / 21

  7. Create the SalesPerson parameter

    Once the data is open in Power Query Editor, create the value that the source query will consume. On the Home tab, select Manage parameters, then New parameter.

    Use a descriptive name that communicates the parameter's purpose. For this example, replace the default name with SalesPerson. A stable, meaningful name matters because that name will be written into the source query expression. The active salesperson value can change later without renaming the parameter itself.

    This command is specifically for definition. New parameter creates a named parameter; Edit parameters is used later to replace the value of a parameter that already exists. Applying or loading commands also do not create a parameter: they commit work performed elsewhere in the workflow.

    7 / 21
  8. Create the SalesPerson parameter

    Configure SalesPerson with these settings:

    Setting Value Meaning here
    Name SalesPerson Identifies the value in the query expression.
    Type Text Matches the salesperson text value passed to the query.
    Suggested Values Any value Uses the required suggested-value setting for this example.

    Select OK to confirm the definition. Power Query then displays the parameter as a new query, which you can select and inspect.

    In this example, the SalesPerson parameter uses the Text data type. Type and Suggested Values are separate settings: Text is the data type, while Any value is the Suggested Values choice. You do not change one into the other before each run, and you do not need to change the parameter type when testing a different salesperson. The input changes while the definition remains stable.

    8 / 21
  9. Quick check

    Which setup correctly creates the parameter used for salesperson values?

    1. AManage parameters → New parameter → SalesPerson → Text → Any value

      Right. New parameter defines SalesPerson with the Text type and Any value as its Suggested Values setting.

    2. BEdit parameters → SalesPerson → Decimal Number → Any value

      Edit parameters modifies an existing parameter, and Decimal Number is not the type used for this salesperson example.

    3. CAdvanced options → SQL statement → SalesPerson → Date/Time

      Advanced options accepts the native SQL statement; it is not the parameter-definition dialog, and Date/Time is not the required type.

    9 / 21

  10. Keep your progress in the app

    That’s 3 of 7 quick checks. In the app they stay answered, and every lesson remembers where you left off.

  11. Bind the parameter to the source query

    Creating SalesPerson does not automatically make the source query use it. The native query must explicitly reference the parameter in place of its fixed salesperson value.

    In Power Query Editor, right-click the source query—Query1 in this example—and select Advanced Editor. Find the existing fixed value in the execute statement. Replace that fixed value with an ampersand (&) followed by the parameter name, SalesPerson.

    The important change is not the query's display name. Renaming Query1 to SalesPerson would leave the execute statement unbound. Removing the execute statement would remove the native query instead of making it adjustable. The required operation happens inside the source expression: the expression must incorporate the parameter's value.

    10 / 21
  12. Bind the parameter to the source query

    Think of the edit as a before-and-after substitution:

    Before After
    Execute statement contains a fixed salesperson value That fixed value is replaced by & SalesPerson
    Every run requests the original salesperson Every run evaluates the active parameter value

    After the replacement, check the bottom of Advanced Editor for errors and select Done. Power BI runs the query with the parameter value, even though the main screen might not show an obvious visual change at that moment.

    This binding is the decisive step. Current Value can only influence the returned data after the source query references SalesPerson. If a later test still returns the original salesperson, inspect the Advanced Editor expression first: it may still contain the old fixed value.

    11 / 21
  13. Quick check

    SalesPerson exists, but changing it does not affect Query1. What should the developer inspect first?

    1. AWhether Close and Apply has renamed the SalesPerson parameter

      Close and Apply returns the resulting data to the report editor; it does not rename the parameter.

    2. BWhether Suggested Values changes from Any value to Text on every run

      Any value and Text are two different settings that remain in place; swapping them per run is neither required nor the cause.

    3. CWhether the query still holds a fixed value

      Right. The source expression must replace the fixed value with an ampersand followed by SalesPerson before parameter changes can affect results.

    12 / 21

  14. Test the parameter in Power Query

    Testing proves that the source query is bound to the parameter before you rely on it in the report. Select the parameter query and enter a different salesperson in the Current Value box.

    If the binding is correct, this new value becomes the input evaluated by the native query. If the returned data does not change, do not keep renaming the parameter or changing its type. Return to the source query's Advanced Editor and verify that the fixed value was actually replaced by the SalesPerson reference.

    Current Value is a field for testing or changing the parameter's active value. It is not a command that creates a parameter, and it does not insert the parameter reference into the native SQL expression. Those earlier definition and binding steps must already be complete.

    13 / 21
  15. Test the parameter in Power Query

    Running the changed value can trigger a warning icon beside the query. The message can state that permission is required to run the native database query. When that happens, select Edit Permission and then Run. Follow this sequence:

    1. Select the affected query to view the warning.
    2. Select Edit Permission.
    3. Select Run.

    Creating another parameter, enabling load, or refreshing the preview does not grant the requested permission. The warning concerns authorization to execute the native query, so it must be handled through Edit Permission and Run.

    When the query runs successfully, the parameter displays the new value. Select Close and Apply to return to the report editor with the resulting data. Close and Apply completes this editor phase; it neither creates the parameter nor binds it to the source query.

    14 / 21
  16. Quick check

    A new Current Value triggers a native database query permission warning. What resolves that warning?

    1. ASelect Edit Permission and then Run

      Right. Edit Permission followed by Run authorizes and executes the native database query.

    2. BSelect Current Value again and then Refresh Preview

      Changing or refreshing the value does not provide the explicit permission requested for native query execution.

    3. CSelect New parameter and then Close and Apply

      Creating another parameter does not authorize the existing native query, and Close and Apply serves a different stage of the workflow.

    15 / 21

  17. Modify and apply an existing parameter

    After the parameter and its source-query reference exist, use the report editing workflow to replace the active value. Select Edit queries, then Edit parameters. In the Edit Parameters window, enter the replacement salesperson value and select OK.

    After changing a parameter through Edit parameters, confirm the value, select Apply changes, and rerun the native query if required. The query then returns data for the new value passed through the parameter.

    The full sequence is therefore:

    Edit queries → Edit parameters → enter value → OK → Apply changes → rerun native query if required

    Do not skip Apply changes: entering a value is the edit, while Apply changes commits it to the report workflow. Do not create a replacement parameter or connection; the existing parameterized query is designed to accept a new value.

    16 / 21
  18. Modify and apply an existing parameter

    Editing a parameter changes the input, not its design.

    Action Changes Does not change
    Edit parameters The active salesperson value The parameter name, purpose, or Text type
    Apply changes Commits the replacement value The source query's binding logic
    Rerun native query Retrieves data for the applied value The report into a separate copy

    For example, if the report currently returns sales for one salesperson and the developer needs to test another, change the existing parameter value, apply the changes, and rerun the native query when required. Keeping the old Text value returns the old salesperson; replacing the SQL Server connection is unnecessary.

    This reuse is the practical payoff: the same report and query design can return a different single salesperson's data simply by receiving a different active value.

    17 / 21
  19. Quick check

    A parameterized report currently returns one salesperson, and the developer needs to test another. Which action is complete?

    1. AEnter a new Current Value, skip Apply changes, and simply close the editor

      Skipping Apply changes omits the step that commits the replacement value in the report workflow.

    2. BChange the parameter value, confirm it, and apply changes to the report

      Right. This reuses the existing parameter and its binding, commits the new value with Apply changes, and executes the native query again when that is required.

    3. CCreate a new SQL Server connection and delete the original query

      The parameterized query already accepts a replacement input, so a new connection and deletion of the working query are unnecessary.

    18 / 21

  20. Diagnose the workflow by stage

    Most parameter problems become simple when you identify the stage that failed.

    Symptom or goal Correct place to look
    Need to define SalesPerson Manage parameters → New parameter
    Need to make Query1 consume it Advanced Editor and the execute statement
    Need to try a value inside Power Query Parameter query → Current Value
    Native-query permission warning Edit Permission → Run
    Need to replace an existing report parameter value Edit queries → Edit parameters
    Need to commit that replacement Apply changes, then rerun if required

    This map also explains the wrong fixes. Navigator is not used to turn a parameter into a model table. Apply changes does not create or bind a parameter. Credentials do not replace the SQL statement. Every command belongs to one specific stage.

    19 / 21
  21. Diagnose the workflow by stage

    A complete implementation creates a Text parameter and replaces the fixed salesperson value with its query reference. In this example, that means both of these steps:

    1. Define SalesPerson as a Text parameter with Any value under Suggested Values.
    2. Replace the native query's fixed salesperson value with its & SalesPerson reference.

    Creating only the parameter leaves the SQL fixed. Changing Current Value without an existing, referenced parameter provides no value that the source expression can evaluate. Removing the native SQL statement also fails because it eliminates the query that should consume the parameter.

    Remember the durable chain:

    Connect → create → bind → test → permit → apply.

    The chain preserves the roles of all three actions: New parameter defines the named, typed value; Advanced Editor binds it to the native query; Edit parameters replaces its active value later. When those roles remain distinct, one report can safely return data for different selected salespeople without rewriting its query.

    20 / 21
  22. Quick check

    Which implementation fully converts a fixed salesperson query into an adjustable one?

    1. ACreate a Text parameter and reference it in the source query

      Right. The parameter defines the adjustable input, and referencing it from the source expression, in place of the fixed value, makes that input control the returned data.

    2. BCreate a Text parameter but leave the fixed SQL value unchanged

      The unreferenced parameter cannot affect a source expression that still uses its fixed value.

    3. CSelect Apply changes and remove the native SQL statement

      Apply changes only commits edits, while removing the native SQL statement eliminates the query that should use the parameter.

    21 / 21

  23. 7 quick checks · then the test

    In the app, finishing the quick checks opens this lesson’s 10-question test, and the ones you miss come back exactly when you’re about to forget them.

The whole course, on your phone

Lessons you can read, audio you can listen to on the way to work, and practice that remembers what you got wrong.