Forum Discussion

PSB's avatar
PSB
Icon for Helper III rankHelper III
3 years ago
Solved

DAX to count values based on condition

I need count column.

for same values in "Category" column, for example fruits but there are three different type of fruits in Product column, I need count as 3.

In vegetable, there are two raws with category "Vegetable" but  in Product there is only one type of vegetable (Eggplant), I need count to be 1.

 

Product

CategoryCount
AppleFruits3
AppleFruits3
PinapleFruits3
BananaFruits3
EggplantVegetable1
EggplantVegetable1
  • Try the following:

    Count Column = CALCULATE(DISTINCTCOUNT(Product), ALLEXCEPT(Category))

     

  • PSB's avatar
    PSB
    3 years ago

    I get this error. could you please share exact formula?

    Too many arguments were passed to the DISTINCTCOUNT function. The maximum argument count for the function is 1.

     

  • Column = CALCULATE(DISTINCTCOUNT('Table'[Product]),ALLEXCEPT('Table','Table'[Category]))

4 Replies

  • Try the following:

    Count Column = CALCULATE(DISTINCTCOUNT(Product), ALLEXCEPT(Category))

     

    • PSB's avatar
      PSB
      Icon for Helper III rankHelper III

      I get this error. could you please share exact formula?

      Too many arguments were passed to the DISTINCTCOUNT function. The maximum argument count for the function is 1.

       

      • PSB's avatar
        PSB
        Icon for Helper III rankHelper III
        Column = CALCULATE(DISTINCTCOUNT('Table'[Product]),ALLEXCEPT('Table','Table'[Category]))