Forum Discussion

lyonslat's avatar
lyonslat
Frequent Visitor
6 years ago

Calculate with multiple criteria

Hi All, 

 

First post, so apologies if it doesn't make a huge amount of sense, but I'm really hoping someone can help me. 

 

Relatively new to DAX, but very familiar with Excel, so most of my logical thinking (& language) comes from there. 

 

Problem

I need to count the number of distinct transactions...

 

Transactions = 
DISTINCTCOUNT('Event1'[check_number])

 

 

...that contain "Food" AND "Beer". 

 

The data I have is formatted in the following table:

 

profit_center_idProfit_center_namecheck_numberrevenue_category_nameItemQty
15M1 Food123456Food1
15M1 Food123456Beer2
15M1 Food123456Misc1
16M2 Beer234567Food1
17M3 Beer345678Beer1
17M3 Beer345678Food2

 

I need more than this, but if I have an answer to this, I can figure the rest out!

 

Thank you!

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable
    Calculate (Distinctcount(table[column]),filter(table,containstring(table[columm_name],"food") || containstring(table[columm_name],"beer")))

    Thanks
    Pravin

    If it resolves your problem mark it as a solution and give Kudos
    • lyonslat's avatar
      lyonslat
      Frequent Visitor

      Hi Pravin, 

       

      Thanks for your input, it's much appreciated. 

       

      Unfortunatley this didn't quite work the way I expected it to. 

       

      The result I'm looking for is to show the number of transactions that contain both Food and Beer. The result that your suggestion put forward, gives me a number of the transactions that contain either food or beer and totals them up. 

       

      Any suggestions?

       

      Thanks, 

      Ben 

      • lyonslat's avatar
        lyonslat
        Frequent Visitor

        The best way I can describe this is if you imagine a venn diagram of transactions.

         

        One side has food transactions, the other has beer, and in the middle you have the number of distinct transactions that contain both food and beer.