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
cdawidow2
Frequent Visitor

CONFUSED WITH USING CONTAINS, CONTAINSSTRING NEED HELP!

Hi guys,  all I want to do is simply count all sales orders that contains at least 1 of the products for a selected order.  My forumla is shown below.  Essentially just confused on how to use contains or containsstring to essentially search for shared values.

 

product.PNGproduct mix.PNG

Any help would be appreciated !
1 ACCEPTED SOLUTION

@cdawidow2 

I will call you table Sales. I assume you are using a card visual. You may try

No of Orders =
VAR SelectedProductds =
    VALUES ( Sales[Products] )
VAR CorrespongingSales =
    FILTER ( ALL ( Sales ), Sales[Products] IN SelectedProductds )
VAR CorrespondingOrders =
    DISTINCT ( SELECTCOLUMNS ( CorrespongingSales, Sales[Order No] ) )
RETURN
    COUNTROWS ( CorrespondingOrders )

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

@cdawidow2 
How does your data look like. Can you share screenshots of the tables and the date model blanking out any sensitive data. 

I only have 1 table - products and orders are in the same table. So if an order has 4 products associated with it then it would have 4 lines 

@cdawidow2 

I will call you table Sales. I assume you are using a card visual. You may try

No of Orders =
VAR SelectedProductds =
    VALUES ( Sales[Products] )
VAR CorrespongingSales =
    FILTER ( ALL ( Sales ), Sales[Products] IN SelectedProductds )
VAR CorrespondingOrders =
    DISTINCT ( SELECTCOLUMNS ( CorrespongingSales, Sales[Order No] ) )
RETURN
    COUNTROWS ( CorrespondingOrders )

Works perfectly! thank you so much!!

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.