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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply

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")

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors