Forum Discussion
Way to query data using SQL and csv file
I want to query my sql database based on some fields in csv file.
When i connect to query can i use the query to connect this way for example.
SELECT Column1
,Column2
,Column3
FROM myDB1.TableName OU
WHERE OU.Column1 IN (
SELECT id FROM Source = Csv.Document
WHERE CSVColumnName IN (“product”, “abc”));
11 Replies
- Phil_SeamarkMicrosoft Employee
Hi NancySharma
I wrote a blog explaining one technique you can use in Power Query to generate dynamic SQL
http://radacad.com/dynamic-sql-using-power-query
- NancySharmaRegular Visitor
Hi Phil,
I am new to Power BI,
What i see is that you made changes to data on Power BI. What i want is that i get prefiltered data from sql based on filter in CSV file so that only needed data gets loaded in power BI.
Reason is when i try to form joins and filter data in power BI, it takes a lot of time when i refresh my CSV file, it has like million records. So what i am looking for is i get prefiltered data uploaded to BI based on CSV filer that i can put in query.
- Phil_SeamarkMicrosoft Employee
Hi NancySharma
All the work should be done in Power Query (which sits before Power BI). You can query your CSV file and you will have to read all of it. Then in Power Query, you can generate a list values from the CSV file that you are interested in and finally use that list inside your T-SQL query statement in the WHERE clause.