Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
rob_vander
Creator
Creator

Need to count common supplier for more than 3 products

Hi All,

I have below dataset. I want to find out count of Orders or list of orders where at least 3 distinct products have one common supplier. In this case Order count will be 2 (10191,102452). I have highlighted rows which satisfies the condition

OrderID,ProductID,SupplierID

10191, 00011, 1088
10191, 00011, 1212
10191, 00011, 1774
10191, 00011,3219
10191, 00013, 1212
10191, 00013,3219
10191, 00033, 1001
10191, 00033,3219
10191, 00032, 0061
102452, 00013, 1212
102452, 00013, 3219
102452, 00027, 3219
102452, 00033, 3219
10297, 00033, 3219
103067, 00033, 1001
103067, 00033, 3219

Note:  I am looking for front end solution first. If it is complex or not possible I will look to do it in script

Labels (3)
1 Solution

Accepted Solutions
Gabbar
Specialist
Specialist

For the Front end try this as a measure:-
Count({<OrderID={"=(Count(distinct ProductID)>=3)"},SupplierID={"=(Count(distinct ProductID)>=3)"}>}distinct OrderID)

and for script you will need to self join the table by applying relevant aggregation functions.

View solution in original post

3 Replies
Chanty4u
MVP
MVP

Try this 

Add OrderID as a dimension

Add the following expression as a measure to count the distinct products per order.

Count(DISTINCT {<ProductID={*}>}

ProductID)

In expression bg color use below exp

If(Count(DISTINCT SupplierID)>2, LightGreen(), White())

 

 

Gabbar
Specialist
Specialist

For the Front end try this as a measure:-
Count({<OrderID={"=(Count(distinct ProductID)>=3)"},SupplierID={"=(Count(distinct ProductID)>=3)"}>}distinct OrderID)

and for script you will need to self join the table by applying relevant aggregation functions.

rob_vander
Creator
Creator
Author

@Gabbar  thanks