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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
EWBWEBB
Helper III
Helper III

Filter overide with && as well as ||

Hi 

I am trying to create a list of distinct dates a customers have entered a store by date but only for a specified set of locations.

 

I seem to be running into an error when I try to add more than one location.

 

My data is laid out as follows

CustomerIDCustomerNamePrimaryMembershipAccessRuleEntryDateTypeLocation
12345BobFull2DAF01/01/2022CycleNorwich
12345BobFull2DAF02/01/2022CycleNorwich
12345BobFull2DAF03/01/2022CycleNorwich
12345BobFull2DAF04/01/2022CycleNorwich
12345BobFull2DAF05/01/2022CycleNorwich
23456JoFull2DAF01/01/2022CarLondon
23456JoFull2DAF02/01/2022CarLondon
23456JoFull2DAF03/01/2022CarLondon
23456JoFull2DAF04/01/2022CarLondon
23456JoFull2DAF05/01/2022CarNorwich
34567JaneFull2DAF01/01/2022CycleClacton
78910AnneFull2DAF01/01/2022CarNorwich
89101TerryFull2DAF01/01/2022CycleLondon
91011MichaelFull2DAF01/01/2022CycleNorwich
10111SteveFull2DAF01/01/2022CycleLondon
11121AlyssaFull2DAF01/01/2022CarClacton
12131MartinFull2DAF01/01/2022CarClacton
13141RobinFull2DAF01/01/2022CarNorwich
15161DaveFull2DAF10/01/2022CarCambridge

 

Using the following I end up with a resulting table that on the face of it seems correct.

 

 

 

DISTINCT(
	SELECTCOLUMNS(
		FILTER(
			Entry,
			Entry[EntryDate] <> BLANK()
			--&& Entry[CustomerID] = 15161
			&& Entry[Location] ="Norwich" || 
				Entry[Location] = "London" || 
				Entry[Location] = "Clacton"
				),
				"_EntryDate",[EntryDate]
			)				
		)

 

 

 

However

 

If remove the comment from 

 

&& Entry[CustomerID] = 15161

 

I would expect the result to be an empty table as they don't have an entry in those locations but I seem to be getting the whole list regardless.

If I ammend the code to just have a single location then i get the blank table as expected.

 

I'm assuming something is going awry with the OR element of this but I can't figure out why.

 

I'm using the ID as a test, I will comment out and filter by ID in the report but I have 160000 rows of data so need to do a little sense checking.

 

Help!

1 ACCEPTED SOLUTION
Shaurya
Memorable Member
Memorable Member

Hi @EWBWEBB,

 

The OR has to be applied only within the condition for checking the location. Everything else will be checked with AND. Brackets will fix your code:

 

DISTINCT(SELECTCOLUMNS(FILTER(Entry,
(Entry[EntryDate] <> BLANK())
&& (Entry[CustomerID] = 15161)
&& (Entry[Location] = "Norwich"
|| Entry[Location] = "London"
|| Entry[Location] = "Clacton")),"_EntryDate",Entry[EntryDate]))

 

Works for you? Mark this post as a solution if it does!
Consider taking a look at my blog: Forecast Period - Previous Forecasts

View solution in original post

2 REPLIES 2
Shaurya
Memorable Member
Memorable Member

Hi @EWBWEBB,

 

The OR has to be applied only within the condition for checking the location. Everything else will be checked with AND. Brackets will fix your code:

 

DISTINCT(SELECTCOLUMNS(FILTER(Entry,
(Entry[EntryDate] <> BLANK())
&& (Entry[CustomerID] = 15161)
&& (Entry[Location] = "Norwich"
|| Entry[Location] = "London"
|| Entry[Location] = "Clacton")),"_EntryDate",Entry[EntryDate]))

 

Works for you? Mark this post as a solution if it does!
Consider taking a look at my blog: Forecast Period - Previous Forecasts

Spot on, that worked like a charm.

 

Thank you

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors