COUNTIFS in PowerBi

Viewed 36

I have a table with the following information. Like shown in the picture I would like to create a column in PowerBi which counts the number of Suppliers a Material number was purchased from. I tried different formulas with distinctcount and filters, but none of them worked.

Table

2 Answers

Here is an example of a calculated column.

First off we invoke CALCULATE since we need to change the evaluation context. You can use the VALUES function to get a 1-column table of the distinct values of a given column. Use ALLEXCEPT to return all rows in the given table for the given material number.

Suppliers = 
CALCULATE ( 
    COUNTROWS ( VALUES ( 'Table'[Supplier] ) ) , 
    ALLEXCEPT ( 'Table' , 'Table'[Material Number] )
)

A

You want to create a new column that COUNT the number of Suppliers per material Number?

Try this New Column:

CALCULATE(COUNT(Suppliers),'Material Number')
Related