Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
lavdeepk
Resolver I
Resolver I

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
Super User

@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

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
DataInsights
Super User
Super User

@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

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.