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

How to create Select query with where clause with AND condition in Power BI

Hi ,

I am creating Power BI reports  and Some SQL queries are like this in which @StartDate,@FinishDate,@DepSelection are query parameter

 

SELECT DISTINCT
p.[ProjectUID], p.[Project code]
FROM Project p
JOIN Assignment abd ON abd.ProjectUID = p.ProjectUID
AND abd.AssignmentWork <> 0
AND abd.TaskIsActive = 1
AND abd.TimeByDay BETWEEN (@StartDate) and (@FinishDate)
WHERE [Project code] is not null
AND ISNULL(p.Archived, 'No') = 'No'
AND p.[Project Departments] IN (@DepSelection)
ORDER BY p.[Lawson Code]

 

How to create above query in Power BI desktop.or complex joins on tables .Urgent Help appreciated!!

6 REPLIES 6
Super User I
Super User I

Re: How to create Select query with where clause with AND condition in Power BI

 

Can achieve by using Parameters in PBI Desktop. Please check below Post or any Post on how to add Parameters in SQL Query in PBI Desktop. Parameters

 

Regards
AJ
Do Like Post if response seems good and Worth liking.
Do Mark as Solution if response resolved your Issue.

 

PranjaliB
Frequent Visitor

Re: How to create Select query with where clause with AND condition in Power BI

Hi Ankit 

I am looking how to create select query in power bi with mutiple joins and logical conditions

Super User I
Super User I

Re: How to create Select query with where clause with AND condition in Power BI

You can directly write your queries using Advanced option in SQL source. It allows using All SQL functions.  Try following steps

1) Write your SQL query in Advanced option. Give sample values instead of variables like FirstDate etc.

2) Once data is imported, create Power BI parameters for your SQL Query.

3) Go to Advanced Editor and Replace sample values with your newly created Parameters. Check the link I shared or any other link online.

4) Click on Refresh, your data will now be imported based on values provided in Parameters.

 

Unfortuately, don't have time to create Source and then End to End PBIX file.

 

 

Capture.PNG

PranjaliB
Frequent Visitor

Re: How to create Select query with where clause with AND condition in Power BI

Hi Ankit,

Thanks for this .But i dont have have sql database as source.I am getting data from Odata feed where i am getting tables and i want to create table/matrix which gives me same output as sql queries after execution.

So basically i want whcih DAX functions i have to use to get same output as above SQL query .

Super User I
Super User I

Re: How to create Select query with where clause with AND condition in Power BI

Ok.. You didn't mention OData source in your requirements. Most of these will be done in Power Query which is ETL for Power BI rather than DAX which is primarily for Data Modelling. Share sample data of your tables and expected output. Then I will have a look but this can take time.

Highlighted
Microsoft v-jiascu-msft
Microsoft

Re: How to create Select query with where clause with AND condition in Power BI

Hi @PranjaliB,

 

If you'd like to show the result in a visual, I would suggest you add the two columns in a Table visual and filter them by the Slicers. If you'd like a calculated table, please try dax/selectcolumns-function-dax and dax/filter-functions-dax. Please share a sample. We can write down a complete formula.

 

Best Regards,
Dale

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

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Join THE global Microsoft Power Platform event series.

Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors