Forum Discussion

st-dat's avatar
st-dat
Helper III
7 years ago
Solved

Calculated column from four other column

Hi,

 

I need help to create a calculated field STATUS from other four columns such as JOB-TYPE, ID-NO, DEPT-ID and STAFF-ID.

Mandatory Conditions that must be met to have "Fulltime" as data under created column

"STATUS" are:

(1) JOB-TYPE must be "Regular"

(2) ID-NO must be "XXXX"

(3) DEPT-ID must contain letter "T"

(4) STAFF-ID must contain "258" and NOT "2580"

IF all the conditions are True, calculated column "STATUS"

will be created with "Fulltime" as data but "blank" if False.

 

JOB-TYPEID-NODEPT-IDSTAFF-IDSTATUS
RegularXXXX0T125890000Fulltime
RegularGGGG0T025804599 
CasualHHHH0P925805670 
RegularXXXX5T025810800Fulltime
CasualXXXX1T925800500 
TempDDDD1M125809990 
RegularXXXX1T925885550Fulltime

 

 Thank you

  • st-dat,

     

    You may refer to the following DAX.

    Column =
    IF (
        Table1[JOB-TYPE] = "Regular"
            && Table1[ID-NO] = "XXXX"
            && SEARCH ( "T", Table1[DEPT-ID],, 0 ) > 0
            && SEARCH ( "258", Table1[STAFF-ID],, 0 ) > 0
            && SEARCH ( "2580", Table1[STAFF-ID],, 0 ) = 0,
        "Fulltime"
    )
    

6 Replies

  • PattemManohar's avatar
    PattemManohar
    Community Champion
    st-dat Did you tried the "Conditional Column" option in "Power Query".
    It will be a straight forward solution there.... Please try...

    Or Are you very particular to solve this in DAX ?
    • st-dat's avatar
      st-dat
      Helper III

      Hi,

       

      Thanks for your prompt response,

      I use PowerPivot excel 2016 and would prefer using DAX because I need the final outcome which is a column with data to achieve another purpose.

       

      Best Regards 

  • v-chuncz-msft's avatar
    v-chuncz-msft
    Community Support

    st-dat,

     

    You may refer to the following DAX.

    Column =
    IF (
        Table1[JOB-TYPE] = "Regular"
            && Table1[ID-NO] = "XXXX"
            && SEARCH ( "T", Table1[DEPT-ID],, 0 ) > 0
            && SEARCH ( "258", Table1[STAFF-ID],, 0 ) > 0
            && SEARCH ( "2580", Table1[STAFF-ID],, 0 ) = 0,
        "Fulltime"
    )
    
    • st-dat's avatar
      st-dat
      Helper III

      Hi Sam,

       

      Thank you for your help, I will update you on the outcome tomorrow.

       

      Esteemed Regards

    • st-dat's avatar
      st-dat
      Helper III

      Hi Sam,

       

      The solution works for me excellently.

       

      Thank you so much.