Forum Discussion

Splyn's avatar
Splyn
Frequent Visitor
7 years ago
Solved

Return all rows from table matching multiple criteria

I have a fact table containing sales data of product broken out by store and brand. I have another table containing a list of brands that I wish to retrieve from the fact table. What im trying to do is for each store within the transaction table, return all matching brands from the Brand table only if ALL brands exist within the store. For example

  • Hi,

     

    Thank you for clarifying and sorry about not reading your question clearly in the first place.  You had alredy clarified my question in your original post.  You may view my Power Query solution in this Excel workbook.  The same can be done in Power BI dektop as well.

     

    Hope this helps.

     

  • hi, Splyn

    Measure = VAR _table=VALUES(Brand[Brand])
    var _table2=CALCULATETABLE(VALUES('Transaction'[Brand]),ALLEXCEPT('Transaction','Transaction'[Store])) return
    CALCULATE(COUNTROWS('Transaction'),FILTER('Transaction', COUNTROWS(EXCEPT(_table,_table2))=0&&'Transaction'[Brand] in _table
    ))

     

     

     

     

     

    Best Regards,
    Lin

     

     

     

     

9 Replies

    • Splyn's avatar
      Splyn
      Frequent Visitor

      Thanks for the reminder. 

      Here is the picture, in text form. 

       

      Transaction table  
      StoreBrandValue
      1a1
      1b2
      1c3
      1b1
      1d2
      2a3
      2c1
      2c2
      2d3
      3b1
      3c2
      3d3
      3a1
      3a2
      3c3
      4a1
      4b2
      4c3
      4d1
      4a2
         
      Brand Table  
      IDBrand 
      1b 
      2c 
         
         
      Results Table  
      StoreBrandValue
      1b2
      1c3
      1b1
      3b1
      3c2
      3c3
      4b2
      4c3
      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

         

        Store 2 has Brand C.  Why should that not appear in your result?

  • v-lili6-msft's avatar
    v-lili6-msft
    Community Support

    hi, Splyn

    Measure = VAR _table=VALUES(Brand[Brand])
    var _table2=CALCULATETABLE(VALUES('Transaction'[Brand]),ALLEXCEPT('Transaction','Transaction'[Store])) return
    CALCULATE(COUNTROWS('Transaction'),FILTER('Transaction', COUNTROWS(EXCEPT(_table,_table2))=0&&'Transaction'[Brand] in _table
    ))

     

     

     

     

     

    Best Regards,
    Lin