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
Jeevan1991
Helper III
Helper III

New Column Based on Other Column

Dear Friends,

 

I have below  data.

Essential or Non EssentialDateCafe & Date & Item CodeStock Status
ESSENTIAL19-Apr-211430070074/19/2021A2338Not Available
ESSENTIAL19-Apr-211430070074/19/2021A2338Stock Available
NON ESSENTIAL19-Apr-211430070074/19/2021A2338Not Available
ESSENTIAL19-Apr-211430070074/19/2021W443Not Available
NON ESSENTIAL19-Apr-211430070074/19/2021W443Not Available
ESSENTIAL19-Apr-211430070074/19/2021W443Not Available
NON ESSENTIAL19-Apr-211430070074/19/2021W443Not Available

I want to arrive new column based on "Cafe & Date & Item Code" & "Stock Status"  & "Essential or Non Essential" column i..e. "New Status" column.

Essential or Non EssentialDateCafe & Date & Item CodeStock StatusNew Status
ESSENTIAL19-Apr-211430070074/19/2021A2338Not AvailableNot Available
ESSENTIAL19-Apr-211430070074/19/2021A2338Stock AvailableNot Available
NON ESSENTIAL19-Apr-211430070074/19/2021A2338Not AvailableNot Available
ESSENTIAL19-Apr-211430070074/19/2021W443Not AvailableNot Available
NON ESSENTIAL19-Apr-211430070074/19/2021W443Not AvailableNot Available
ESSENTIAL19-Apr-211430070074/19/2021W443Not AvailableNot Available
NON ESSENTIAL19-Apr-211430070074/19/2021W443Not AvailableNot Available

Column "Cafe & Date & Item Code" contains duplicate data and if "Essential or Non Essential" is "Essential" and "Stock Status" is "Not Avilable" and for any one of the "Essential" of "Cafe & Date & Item Code" column then "New Status" should be "Not Available" only.

 

For an example take a look at the first 3 rows.

Essential or Non EssentialDateCafe & Date & Item CodeStock StatusNew Status
ESSENTIAL19-Apr-211430070074/19/2021A2338Not AvailableNot Available
ESSENTIAL19-Apr-211430070074/19/2021A2338Stock AvailableNot Available
NON ESSENTIAL19-Apr-211430070074/19/2021A2338Not AvailableNot Available

In this first two are essential but for first row "Stock Status" is "Not Available" and for second row "Essential" and stock status is "Stock Available", since the first one is already "not available" then this also should be "not available" only.

 

@Minakshi @Anonymous @Jihwan_Kim @amitchandak @parry2k @Geradav @PhilipTreacy @Kinjal @Sujit_Thakur 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Jeevan1991 , Try a new column like

new column =
var _cnt = countx(filter(Table, [Cafe & Date & Item Code] =earlier([Cafe & Date & Item Code]) && [Essential or Non Essential] = "ESSENTIAL" && [Stock Status] = "Not Available" ), [Cafe & Date & Item Code] ) +0
return
if( _cnt >0 , "Not Available" ,[Stock Status])

 

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Jeevan1991 , Try a new column like

new column =
var _cnt = countx(filter(Table, [Cafe & Date & Item Code] =earlier([Cafe & Date & Item Code]) && [Essential or Non Essential] = "ESSENTIAL" && [Stock Status] = "Not Available" ), [Cafe & Date & Item Code] ) +0
return
if( _cnt >0 , "Not Available" ,[Stock Status])

 

Thanks you so much @amitchandak  it worked wonders for me.

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.