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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
SUGISUGAN
Frequent Visitor

Dynamic SQL View based on button click

Hi, I am new to power bi. My requirement is to have 3 button in Home Page, General Raw data view in General Page.                     On click of Button1 - General Page report must bind data with View1  like select * from View1

On click of Button2 - General page report must bind data with View2 (select * from View2)

On click of button3 - render data from View3(select * from view3)

all columns are same in 3 views and i have to dynamically pass this on button click.

Kindly help how to achieve this in desktop and the functionality must work in service too.

power bi version using: Version: 2.136.1202.0 64-bit (September 2024)

1 ACCEPTED SOLUTION

Hi @SUGISUGAN 

Great to hear, if it worked please mark as a solution.

 

Best way to find out is giving it a try. Direct Queries by their very nature are slower than imported data.

The alternative is having 3 bookmarks for the same page with different visuals for the different views or 3 seperate pages for the 3 views.

Both of those require a more complicated report but in theory may run faster.

 

Make sure to go into Settings -> Current Report -> Query Reduction and make use of the options there. These will help with the direct query running smoother.


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

View solution in original post

5 REPLIES 5
SUGISUGAN
Frequent Visitor

Hi Sam,

I would request a help in advance to it.. to pass the view name dynamically based on button click using parameterization. As my views will be deployed one after the other, i cannot proceed with append option.. 

A dynamic SQL query takes view name and a change in the layout will be adding new button and pass the new view to the existing parameterized code. WIl this work on desktop and service?

 

SamWiseOwl
Super User
Super User

Hi @SUGISUGAN 

 

Have you considered using the Append feature?

Connect to each view the Query Editor.

Add a custom column called Number and for the view_1 have 1 for 2 etc

SamWiseOwl_1-1729671693425.png

 

Then Append all 3 views together.

SamWiseOwl_0-1729671634130.png

 

Create 3 bookmarks that save the Single query filtered to the 3 different values.

SamWiseOwl_2-1729671746216.png

 

Add a bookmark navigator to switch between them or have 3 seperate buttons that go to a bookmark,

SamWiseOwl_3-1729671782903.png

 


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

HI SAM,

 

I got the result as expected and made tweaks accessing the bookmark from a button click.

Thanks a lot for your valuable time.

I have a question on performance. as we are appending, and all the views are executed at once.

Volume of data approximately is View 1 : 10lac (per year) , View 2 (75000 per year).. and i am rendering the data for 3 years.. will we get any performance issue? 

Hi @SUGISUGAN 

Great to hear, if it worked please mark as a solution.

 

Best way to find out is giving it a try. Direct Queries by their very nature are slower than imported data.

The alternative is having 3 bookmarks for the same page with different visuals for the different views or 3 seperate pages for the 3 views.

Both of those require a more complicated report but in theory may run faster.

 

Make sure to go into Settings -> Current Report -> Query Reduction and make use of the options there. These will help with the direct query running smoother.


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Hi Sam,

 

Thanks for your reply, let me try this option and confirm you at the earliest..

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.