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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Creating a table in Power BI with SQL query

Hello,

 

I would like to make a table in Power BI and have this SQL query. Can you help me how to fit these conditions into Power BI?

 

Any help highly appretiated.

1 ACCEPTED SOLUTION
AbhinavJoshi
Responsive Resident
Responsive Resident

Hi @Anonymous . If you are trying to query your database using Power BI and get the data there. Simply go to Get Data and select your sql data source. You would then be promted to enter the credentials. Then, enter you sql query in the SQL statement option.

AbhinavJoshi_1-1727714056637.png

 

AbhinavJoshi_0-1727713835253.png

I hope it helps!

Abhinav

 

View solution in original post

4 REPLIES 4
AbhinavJoshi
Responsive Resident
Responsive Resident

Hi @Anonymous . I'm glad you have a starting point. If I understand this correctly for your second question, you can get rid of the dates in your where clause and let the user decide the dates/years they wanna see the data. Have the date column in your select clause and then use it to in slicer. Does this makes sense? 

Anonymous
Not applicable

Yes it works but partly, Thank you. 

AbhinavJoshi
Responsive Resident
Responsive Resident

Hi @Anonymous . If you are trying to query your database using Power BI and get the data there. Simply go to Get Data and select your sql data source. You would then be promted to enter the credentials. Then, enter you sql query in the SQL statement option.

AbhinavJoshi_1-1727714056637.png

 

AbhinavJoshi_0-1727713835253.png

I hope it helps!

Abhinav

 

Anonymous
Not applicable

This works but I came across a one problem, I will need to change dates for criteria in red circles on the picture , how can I challege that in Power BI... I would like to use a simple slicers for dates, in Power BI to setup up dates criteria. Of course manually change code  is simple but it has to work automatically, date slicers for users.

poko_0-1727792250964.png

it should look like this (those data below are result of above I posted(SQL query)) but I will need to change "Years". This one below is for 2023 

poko_1-1727793643898.png

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.