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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
s--turn
Helper II
Helper II

Parameter (or variable) to use different tables?

Hello,

 

I have a few tables, all with different names (let's say Question1, Question2 etc - it's survey data), but each containing the same named fields:

 

Respondent ID

Attribute

Value

 

I'd like to create a single visual, with slicer allowing the user to select which table's data they want to use. I have a hunch this could possibly be achieved with parameters, but I've got myself confused about exactly how.

 

Any ideas welcome!  Thanks.

1 ACCEPTED SOLUTION
ribisht17
Super User
Super User

Hi @s--turn 

 

Sounds like you need to UNION here which will help you to slice and dice

 

https://learn.microsoft.com/en-us/dax/union-function-dax

 

Regards,

Ritesh

Mark my post as a solution if it helped you| Munde and Kudis (Ladies and Gentlemen) I like your Kudos!! !!
My YT Channel Dancing With Data !! Connect on Linkedin !!Power BI for Tableau Users 

View solution in original post

3 REPLIES 3
s--turn
Helper II
Helper II

Thanks so much, both @Jaywant and @ribisht17 !  Jaywant - reading your solution was so interesting and taught me some things I didn't know before.  I was all poised to try it - and then Ribisht17 came in with an incredibly simple idea which I couldn't resist, and which solves the problem perfectly!  (I've actually used Append in Power Query rather than UNION in DAX, with an extra column for the query name, but same principle).  Thanks so much, both of you 🙂 

Jaywant
Regular Visitor

To create a single visual that allows users to select the table's data they want to use based on a slicer, you can utilize Power BI's query parameters. Here's how you can achieve this:

  • Open Power Query Editor from the Home tab in Power BI Desktop.

  • Create a new query by selecting "New Source" and choosing "Blank Query".

  • In the formula bar, define the following query to retrieve the list of table names:

TableNames = {"Question1", "Question2", "Question3"} // Replace with actual table names

Modify the list of table names to match your specific table names. You can add as many table names as required.

  • Close and apply the changes to create the query.

  • Now, go to the "Home" tab and click on "Manage Parameters".

  • In the Manage Parameters dialog box, click on "New Parameter" to create a new parameter.

  • Configure the parameter with the following settings:

    • Name: SelectTable
    • Data type: Text
    • Allowed values: List of values
    • Suggested values: TableNames (select the "TableNames" query you created earlier)
    • Current value: Question1 (or any default table name you prefer)
  • Click OK to create the parameter.

  • Next, create a new query by selecting "New Source" and choosing "Blank Query".

  • In the formula bar, define the following query to retrieve the selected table based on the parameter:

SelectedTable = Table.SelectRows(Excel.CurrentWorkbook(){[Name=Parameters[SelectTable]{0}[Value] & "_Table"]}[Content], each true)
  • This query uses the parameter value to dynamically select the table by appending "_Table" to the parameter value.

  • Close and apply the changes to create the query.

  • Now, you can create your visual (e.g., a table or chart) using the "SelectedTable" query as your data source.

  • Add a slicer visual to your report canvas and select the "SelectTable" parameter as the field for the slicer.

  • When users interact with the slicer, the visual will automatically update to display the data from the selected table.

By using query parameters, you can dynamically switch between different tables and have a single visual that adapts to the user's selection.

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

 

ribisht17
Super User
Super User

Hi @s--turn 

 

Sounds like you need to UNION here which will help you to slice and dice

 

https://learn.microsoft.com/en-us/dax/union-function-dax

 

Regards,

Ritesh

Mark my post as a solution if it helped you| Munde and Kudis (Ladies and Gentlemen) I like your Kudos!! !!
My YT Channel Dancing With Data !! Connect on Linkedin !!Power BI for Tableau Users 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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