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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
spin1888
Frequent Visitor

Help with Creating a Measure that Excludes Customers with No Sales from Two Other Measures

I have a matrix visual row grouped by Customer, Product Category and Sub Product Category and three measures as values. However, on Measure 3 I want to exclude customers that had no sales in Measure 1 OR Measure 2 as the business is not interested in them for this study. I can't seem to figure out how to exclude in Measure 3 those customers we are not interested in looking at. The outcome always ends up including those customers of no interest.

 

I have tried using:

Flag = IF([Measure 1] || [Measure 2],1,0)

 

But I lose the respected total summarization in scope of the sub category totals and Grand total unexpectedly.

 

How do I go about summarizing Measure 3 to exclude customers with no sales in Measure 1 OR Measure 2 like the screenshot below keeping in mind that I will be adding and expanding by Customer, Product Category and then Product Sub Category:

Problem

spin1888_1-1671362912546.png

 

Expected Result:

spin1888_2-1671362936650.png

 

Below are the measures used (*** rewrote the measures below to keep it simplistic):

- Star Schema Data Model containing a dimProduct, dimCustomer and factSales table

spin1888_0-1671363749109.png

 

Measure 1 = CALCULATE(

    [LineAmountUSD],
    FILTER('Product','Product'[Category]="Clothing")
)
 
Measure 2 = CALCULATE(
    [LineAmountUSD],
    FILTER('Product','Product'[Category]="Components")
)

Measure 3 = CALCULATE(
    [LineAmountUSD],
    FILTER('Product','Product'[Category]="Bikes")
)
 
*** The condition for Measure 3 shall sum [Line Amount USD] and filter on "Product 3" AND must exclude Customers with no sales in Measure 1 OR Measure 2
1 ACCEPTED SOLUTION

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

18 REPLIES 18
FreemanZ
Super User
Super User

Hi @spin1888 

How many relevant tables do you have and how are they related?

It seems you have a dimProduct table, at least a sales record table and maybe a customer table.

Sorry about that; it is a star schema data model that has a dimProduct, dimCustomer and factSales tables

can you describe how they are related and provide some sample data of each table?

Unfortunately I can't provide sample data due to the sensitive nature but have a AdventureWorks pbix file mimicing the same scenerio.

Ashish_Mathur
Super User
Super User

Hi,

Does this measure work?

Measure 3 = CALCULATE ( [Line Amount USD], FILTER(dimProduct, ProductCategory = "Product 3"&&[Measure 2]<>blank()&&[Measure 1]<>blank())) 

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks Ashish that worked but returned incorrect results. For example Customer A that had sales in Measure 1 and Measure 2 displayed $300 worth of sales for Measure 3 but I know for sure they are suppose to have $4,000 in sales.

Hi,

I will need to see the PBi file.  Show the problem there clearly and also show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Sure; what is the best way to send a pbix file. I have created a pbix file using the AdventureWorks as source and mimic the same scenerio I am working on.

Upload the file to Google Drive/One Drive and share the download link.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Measure 3 =
VAR __tbl = CROSSJOIN ( VALUES ( Customer[Customer] ), VALUES ( 'Product'[Category] ))
VAR _m3 =
CALCULATE (
[LineAmountUSD],
FILTER ( 'Product', 'Product'[Category] = "Bikes" )
)
RETURN
IF (
NOT ( ISBLANK ([Measure 1] ) ) || NOT ( ISBLANK ([Measure 2] ) ),
IF (
ISINSCOPE ( Customer[Customer] ),
_m3,
SUMX (__tbl,_m3)))Screen Capture #169.png

Thank you Ashish;
We are getting close. The following below worked as needed keeping the grand total at $94 M:

Measure 3 =
IF(NOT(ISBLANK([Measure 1])) || NOT(ISBLANK([Measure 2])),
CALCULATE(
    [LineAmountUSD],
    FILTER('Product','Product'[Category]="Bikes")
)
)
spin1888_0-1671463888462.png

 

 The measure using the INSCOPE function worked but threw the grand totals way off:
spin1888_1-1671464018606.png
 
However, $94 M was not the expected result when I sum up Measure 3. I was expecting the following in the tab "Expected Result":
spin1888_2-1671464412008.png

 

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hey Ashish;

 

I tried to replicate it however I am noticing my results are coming in blank for [Measure] and [Measure 4]. Also, noticed that [Measures 1] and [Measure 2] repeat itself for every product category:

 

New File:

spin1888_0-1671510868562.png

 

Replicated Tab:

spin1888_1-1671510965103.png

 

Recheck everything with my solution file.  If you are still unable to solve, then share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Beautifully well written. Thank you!!

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors