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 conditions

Hi All,

 

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

Refer to the below sample data there are 4 products against a single Cust Code. My condition is if a Cust Code has this product "5"  then mark as "YES" else "NO " against Cust Code .(refer to desired results )

 

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

 

Cust CodeProductStatus desired results
A1NO
A2NO
A3NO
A4NO
B1YES
B2YES
B3YES
B5YES
C1NO
C2NO
C3NO
C4NO
D5YES
D2YES
D3YES
D4YES
2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Picture1.png

 

Result CC : =
VAR _currentcustcode = Data[Cust Code]
VAR _filtertableproduct =
SUMMARIZE ( FILTER ( Data, Data[Cust Code] = _currentcustcode ), Data[Product] )
RETURN
IF ( 5 IN _filtertableproduct, "YES", "NO" )

 

https://www.dropbox.com/s/2o32swo7r1aidwu/lavdeepkv2.pbix?dl=0 

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

Migasuke
Super User
Super User

Hi @lavdeepk ,
You can try following solution:

Migasuke_0-1626936692459.png

 



If my answer was helpful please give me a Kudos or even accept as a Solution.

Let's connect on LinkedIn!

View solution in original post

4 REPLIES 4
Migasuke
Super User
Super User

Hi @lavdeepk ,
You can try following solution:

Migasuke_0-1626936692459.png

 



If my answer was helpful please give me a Kudos or even accept as a Solution.

Let's connect on LinkedIn!

Hi @Migasuke 

 

This is working fine

I appreciate your help so much

 

Arul
Super User
Super User

Hi @lavdeepk ,

 

Kindly check the below DAX formula.

 

Calculated column = IF(OR('Table'[Cust Code]="A",'Table'[Cust Code]="C"),"NO","YES")

Arul_0-1626936679128.png

 

 

 

Thanks,

-Arul

 





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

Proud to be a Super User!


LinkedIn


Jihwan_Kim
Super User
Super User

Picture1.png

 

Result CC : =
VAR _currentcustcode = Data[Cust Code]
VAR _filtertableproduct =
SUMMARIZE ( FILTER ( Data, Data[Cust Code] = _currentcustcode ), Data[Product] )
RETURN
IF ( 5 IN _filtertableproduct, "YES", "NO" )

 

https://www.dropbox.com/s/2o32swo7r1aidwu/lavdeepkv2.pbix?dl=0 

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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.