cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CauseAndEffect
Helper I
Helper I

Elegant function for filtering using more than two critera

Hey hey fine folk of PBI!

Trying to create a reusable measure of customer sales per region, the issue is that the database does not have the regions setup.

My need is something like this

Count all sales for customers in asia.

Asia_sales = CALCULATE(COUNT(RawDataTable[Total Sales]);
FILTER(RawDataTable;(RawDataTable[Company location] = "Indonesia North" && (RawDataTable[Company location] = "Indonesia South") && (RawDataTable[Company location] = "Indonesia east") 

Above was just an example to get the gist of what I'm trying to accomplish. Any tips for how to do this in the most "elegant" way?

In the end, I will try to SUM the data by region with all the data of the companies included. Thanks!
3 REPLIES 3
RickPowerBI
Helper I
Helper I

Hi @CauseAndEffect,

 

Try using FIND or SEARCH, You would get something like this:

(Bare in mind, i'm not an expert so this may not work at all but it may give you an idea of how to fix your problem)

Asia_sales = 
CALCULATE ( COUNT ( RawDataTable),
FILTER ('RawDataTable',
NOT (
ISBLANK (
FIND ("Indonesia North", [Company location], , BLANK ())))
|| NOT (
ISBLANK (
FIND ("Indonesia South", [Company location], , BLANK ())))
|| NOT (
ISBLANK (
FIND ("Indonesia east", [Company location], , BLANK ()))),
[Total Sales])

 

Solved it, just created a Calculate using the correct syntax

New Measure ->

 

00_Countryfilter = CALCULATE(COUNT(RawDataTable[Sales]);
RawDataTable[Store Location] = "Indonesia East" ||
RawDataTable[Store Location] = "Indonesia West" ||
RawDataTable[Store Location] = "Indonesia South" ||
RawDataTable[Store Location] = "Japan South" ||
RawDataTable[Store Location] = "Japan South IKU")
CauseAndEffect
Helper I
Helper I

Optimally i need to use an unlimied amount of filters since our customer location column has over 2k unique locations.

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors