cancel
Showing results for
Did you mean:
Helper III

## How to create a calculated column based on some conditions in Power Bi

I am struggling to create a calculated column based on some conditions in Power Bi.

Refer to the below sample data there are 4 Branch codes against a single Customer. My condition is if a Customer no has this item code "12000" then mark as "Direct Sale " else "Corp Sale " for that Customer all txn .(refer desired results )

 Customer Branch Code Cust Type ((desired results) CUST-34212 12902 Corp Sale CUST-34212 12087 Corp Sale CUST-34212 12921 Corp Sale CUST-34212 12003 Corp Sale CUST-687768 12902 Direct Sale CUST-687768 12000 Direct Sale CUST-687768 12921 Direct Sale CUST-687768 12003 Direct Sale CUST-752061 12902 Direct Sale CUST-752061 12000 Direct Sale CUST-752061 12921 Direct Sale CUST-752061 12003 Direct Sale CUST/018305 12902 Corp Sale CUST/018305 12909 Corp Sale CUST/018305 12921 Corp Sale CUST/018305 12003 Corp Sale CUST/018300 12902 Direct Sale CUST/018300 12000 Direct Sale CUST/018300 12921 Direct Sale CUST/018300 12003 Direct Sale
1 ACCEPTED SOLUTION
Super User II

Try this calculated column:

``````Cust Type =
VAR vCount =
CALCULATE (
COUNT ( Table1[Branch Code] ),
ALLEXCEPT ( Table1, Table1[Customer] ),
Table1[Branch Code] = "12000"
)
VAR vResult =
IF ( vCount > 0, "Direct Sale", "Corp Sale" )
RETURN
vResult``````

Super User II

Try this calculated column:

``````Cust Type =
VAR vCount =
CALCULATE (
COUNT ( Table1[Branch Code] ),
ALLEXCEPT ( Table1, Table1[Customer] ),
Table1[Branch Code] = "12000"
)
VAR vResult =
IF ( vCount > 0, "Direct Sale", "Corp Sale" )
RETURN
vResult``````

Announcements

#### Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.