The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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.
Solved! Go to Solution.
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
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 🙂
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:
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.
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
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
114 | |
79 | |
78 | |
47 | |
39 |
User | Count |
---|---|
147 | |
115 | |
65 | |
64 | |
53 |