Biswa
Biswa

Reputation: 331

Using if in power bi dax

I have a table which has 2 columns , Branch and role. Basically I want 3rd column which will say 1) if a branch has all the three role (President,Treasurer,Secretary) then 1. 2) If a branch has 2 roles (President,Treasure/secretary) then 2 3) if a branch has 1 role (President/treasurer/secretary) then 3.

How m i going to achieve this. Below is my table structure.

enter image description here

Upvotes: 0

Views: 56

Answers (1)

Aldert
Aldert

Reputation: 4313

You can do this by counting the rows of the branch, add a new column:

    YouGet = 
var br = Branch[Branch]
return 4 - CALCULATE(COUNTROWS(Branch);FILTER(Branch;br = Branch[Branch] && (Branch[Role] = "President" || Branch[Role] = "Secretary" || Branch[Role] = "Treasurer")))

4 - the row count is to get the result in line with what you ask for.

You can also choose to create a second table with the3 items and a relation between the tables. This gives the advantage that you can extend.

Upvotes: 1

Related Questions