Forum Discussion

cdawidow2's avatar
cdawidow2
Frequent Visitor
4 years ago
Solved

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.

 


Any help would be appreciated !
  • tamerj1's avatar
    tamerj1
    4 years ago

    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 )

4 Replies

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

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

    • cdawidow2's avatar
      cdawidow2
      Frequent Visitor

      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 

      • tamerj1's avatar
        tamerj1
        Icon for Community Champion rankCommunity Champion

        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 )