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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
daveedd
Helper II
Helper II

Report Builder DA Query builder OR query across 2 columns

Hi all,

 

I'm building a Paginated report in report builder (not desktop) which has 2 Account fields, AccountName and AccountParent.

 

I have a parameter related to each and want people to be able to search on either.  So the query would look like:  [AccountName] = parameter1.value  OR  [AccountParent] = parameter2.value.

 

Could anyone help with the syntax here, I've been scratching my head for a few hours.

2 REPLIES 2
hackcrr
Super User
Super User

Hi, @daveedd 

To create paged reports in Report Builder to filter data based on or AccountName, AccountParent You can define parameters and then build queries to use those parameters with OR conditions.

Step 1: Define the parameters

Open your report in the Report Builder. In the Report Data pane, right-click Parameters and select Add Parameter twice to create two parameters:
Parameter 1: For AccountName
Parameter 2: For AccountParent

Configuration parameters:
Parameter 1:
Name: AccountName
Data type: text
Hint: Enter the account name
Parameter 2:
Name: AccountParent
Data type: text
Hint: Enter the parent account

 

In the Report Data pane, right-click the dataset and select Dataset Properties.
In the Query section, modify the SQL query to use parameters with OR conditions. The following is an example:

SELECT *
FROM YourTableName
WHERE (@AccountName IS NULL OR AccountName = @AccountName)
   OR (@AccountParent IS NULL OR AccountParent = @AccountParent)

This query uses the parameters @AccountName and @AccountParent. it checks if each parameter is NULL (i.e., not specified by the user) and includes the condition if it is.
Go to the Parameters tab in the Dataset Properties window and make sure that the parameters correctly map @AccountName to @AccountParent to the report parameters.

 

hackcrr

If this post helps, then please consider Accept it as the solution and kudos to this post to help the other members find it more quickly

Thanks for the response.  I have the parameters set up, but still struggling with the query.  I'm connecting to a Power BI semantic model so having to use DAX rather than SQL

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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