cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Zuhebsayed
Frequent Visitor

Power BI Desktop SQL query builder

Hi All,

I need some help. I am working On power with SQL server. Having some issues would be great help if anyone can suggest some solutions

I am tying to load a table from a database using import query in power bi desktop. Query like db.abc_xyz '2017-03-01', '2017-03-31' now this query return all data between those date ranges. Which work for me. But now I want to extract for 1st April, it create new query and table everytime. Is there any way I can append data beneath the old one. I mean everytime I refresh the power bi new data must append in the particular table.

Also is there any way I can provide user interface which may ask for date range every time I run data extraction query
1 ACCEPTED SOLUTION

Modify the T-SQL query will return one additional row which contains date "2017-4-1" compares to the original result.

 

You can try those two ways in your desktop.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-qiuyu-msft
Community Support
Community Support

Hi @Zuhebsayed,

 

Assume you write the T-SQL query when you get data from SQL Server database to filter data between date range '2017-03-01', '2017-03-31', you can open Query Editor -> Advanced Editor, then modify the T_SQL query to include 1st April (eg: replace "2017-3-31" as "2017-4-1")

 

q1.PNGq2.PNG

 

In Power BI desktop, there is Query Parameter feature for us to filter data dynamically. You can create two parameters "StartDate" and "EndDate", then use those two parameters to filter date column. For more information, see: Deep Dive into Query Parameters and Power BI Templates .

 

q3.PNG

 

 

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks v-qiuyu-MSFT,

 

But does it will replace all data in the query or just append 1st Apr data. I don't want duplicates data.

Modify the T-SQL query will return one additional row which contains date "2017-4-1" compares to the original result.

 

You can try those two ways in your desktop.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors