cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lavdeepk
Helper III
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 )

 

Please help me with the DAX formula to achieve desired results.

 

CustomerBranch CodeCust 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
DataInsights
Super User II
Super User II

@lavdeepk,

 

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

 

DataInsights_0-1626996174701.png

 

View solution in original post

1 REPLY 1
DataInsights
Super User II
Super User II

@lavdeepk,

 

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

 

DataInsights_0-1626996174701.png

 

View solution in original post

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

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

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors