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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Manudata
Frequent Visitor

Help counting suppliers based on measure/condition

This is the problem:

 

My tables are linked like this

TABLE_SUPPLIERS_PRODUCT_MANAGER.CodeManager    =   TABLE_ORDERS.CodeManager

 

TABLE_SUPPLIERS_PRODUCT_MANAGER

CodeSupplierCodeProductCodeManager (PK)Have Orders
ATablesManager 001Y
AChairsManager 002N
AChairsManager 003Y
BTablesManager 004Y
BTablesManager 005N
BChairsManager 006Y
BShelvesManager 007N
CShelvesManager 008N

 

 

TABLE_ORDERS

OrderNumberCodeManagerCodeProductUnits
0001Manager 001Tables10
0002Manager 001Tables1
0003Manager 003Chairs10
0004Manager 006Chairs20
0005Manager 004Tables20
    

 

 

 

So, I have the following measure:

 

No. Registered suppliers = DISTINCTCOUNT(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeSupplier])

No. Registered suppliers with orders= 
CALCULATE([No. Registered suppliers], FILTER(TABLE_SUPPLIERS_PRODUCT_MANAGER, TABLE_SUPPLIERS_PRODUCT_MANAGER[HaveOrders]="Y"))

 

 

And now I want:

  • No. Registered suppliers without orders
  • And the possibility of seeing who they are on a list
  • One question: User can filter by CodeProduct

This measure not works

No. Registered suppliers without orders= CALCULATE([No. Registered suppliers], FILTER(TABLE_SUPPLIERS_PRODUCT_MANAGER, TABLE_SUPPLIERS_PRODUCT_MANAGER[HaveOrders]="N"))

 

Because this includes suppliers who, perhaps with another product have orders.

 

With the data I have provided, this value should give

 

  • No. Registered suppliers with orders: 2
  • No. Registered suppliers without orders: 1

If the user filters to see only SHELVES products, the measurements would be

  • No. Registered suppliers with orders: 0
  • No. Registered suppliers without orders: 1

If the user filters to see only CHAIRS products, the measurements would be

  • No. Registered suppliers with orders: 2
  • No. Registered suppliers without orders: 0
1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Manudata 

 

You can try the following methods.

Column:

Column YN = CALCULATE(MAX(TABLE_SUPPLIERS_PRODUCT_MANAGER[Have Orders]),ALLEXCEPT(TABLE_SUPPLIERS_PRODUCT_MANAGER,TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeSupplier]))

vzhangti_0-1698061287878.png

Measure Y = CALCULATE(DISTINCTCOUNT(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeSupplier]),FILTER(ALL(TABLE_SUPPLIERS_PRODUCT_MANAGER),[CodeProduct]=MAX(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeProduct])&&[Have Orders]="Y"))+0
Measure N = 
Var _N1=CALCULATE(DISTINCTCOUNT(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeSupplier]),FILTER(ALL(TABLE_SUPPLIERS_PRODUCT_MANAGER),[CodeProduct]=MAX(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeProduct])&&[Have Orders]="N"))+0
Var _N2=CALCULATE(DISTINCTCOUNT(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeSupplier]),FILTER(ALL(TABLE_SUPPLIERS_PRODUCT_MANAGER),[CodeProduct]=MAX(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeProduct])&&[Column YN]="N"))+0
Return
IF(SELECTEDVALUE(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeProduct])=BLANK(),_N1,_N2)

vzhangti_3-1698061386347.pngvzhangti_4-1698061396483.pngvzhangti_5-1698061407660.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

 

View solution in original post

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @Manudata 

 

You can try the following methods.

Column:

Column YN = CALCULATE(MAX(TABLE_SUPPLIERS_PRODUCT_MANAGER[Have Orders]),ALLEXCEPT(TABLE_SUPPLIERS_PRODUCT_MANAGER,TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeSupplier]))

vzhangti_0-1698061287878.png

Measure Y = CALCULATE(DISTINCTCOUNT(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeSupplier]),FILTER(ALL(TABLE_SUPPLIERS_PRODUCT_MANAGER),[CodeProduct]=MAX(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeProduct])&&[Have Orders]="Y"))+0
Measure N = 
Var _N1=CALCULATE(DISTINCTCOUNT(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeSupplier]),FILTER(ALL(TABLE_SUPPLIERS_PRODUCT_MANAGER),[CodeProduct]=MAX(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeProduct])&&[Have Orders]="N"))+0
Var _N2=CALCULATE(DISTINCTCOUNT(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeSupplier]),FILTER(ALL(TABLE_SUPPLIERS_PRODUCT_MANAGER),[CodeProduct]=MAX(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeProduct])&&[Column YN]="N"))+0
Return
IF(SELECTEDVALUE(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeProduct])=BLANK(),_N1,_N2)

vzhangti_3-1698061386347.pngvzhangti_4-1698061396483.pngvzhangti_5-1698061407660.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

 

speedramps
Super User
Super User

 

Create this measure

Has orders =
// If context has any orders then return 1, else return null
INT(NOT(ISEMPTY(TABLE_ORDERS)))

No. Registered suppliers with orders =
// create a temporary table of just suppliers with orders
VAR suppliers_without_orders = FILTER(VALUES(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeSupplier]),[Has orders] = 1)
RETURN
// count the suppliers on the temporary table
COUNTROWS(suppliers_without_orders)

No. Registered suppliers without orders =
// create a temporary table of just suppliers with no orders
VAR suppliers_without_orders = FILTER(VALUES(TABLE_SUPPLIERS_PRODUCT_MANAGER[CodeSupplier]),[Has orders] = 0)
RETURN
// count the suppliers on the temporary table
COUNTROWS(suppliers_without_orders)


To see which suppliers a
re on a list,  use the [Has orders] as a filter
 
speedramps_0-1697997780822.png

 


This solution will alow you to add a product silicer
 

Thanks for the clear description of the problem with example data. I wish everyone did that!

Remember we are unpaid volunteers. So please click the thumbs up and the [accept as solution] button to leave kudos. 

One question per ticket please. If you need to extend your request then please raise a new ticket.

If you quote @speedramos in your next tickets then I will then receive an automatic notification, and will be delighted to help you again.

Please click the thumbs up and the [accept as solution] button now.  Thank you.

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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