Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

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 

  • Anonymous , 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])

     

2 Replies

  • Anonymous , 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])

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks you so much amitchandak  it worked wonders for me.