Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
durgabhavani
Creator III
Creator III

Help me to derive new field based on my two fields?

Hi All,

Can you please help me to compare two fields and derive new field (New Severity). Please find my sample data and expected output column.

   

Initial SeverityLatest SeverityNew Severity (Expected Output)
HighLowN/A
LowMedMed
MedHighHigh
HighLowN/A
MedHighHigh
LowHighHigh
MedLowN/A
HighMedN/A
LowMed

Med

21 Replies
durgabhavani
Creator III
Creator III
Author

Got this point. just now comment the first part of the code in sample and ran the application.

Able to get below output. How are values 1,2,3 assigned to rank fields. (Is that match funcitionality?) Confused. Please explain.

sunny_talwar

Yup, Match is doing that....

Assigns the number based on the value

Match([Initial Severity], 'Low', 'Med', 'High')

Low is 1st... so gets 1

Med is 2nd... so gets 2

High is 3rd... so gets 3



durgabhavani
Creator III
Creator III
Author

Not working as expected. see below. highlighted records are wrong. Expecting N/A instead of Med, Med instead of N/A on highlighted simulatenously.

durgabhavani
Creator III
Creator III
Author

Ok. Can we assign directly numbers to high, med, low instead of match?

sunny_talwar

ApplyMap is another option... but what is wrong with Match?

durgabhavani
Creator III
Creator III
Author

due to my existing code. May be not able to use Match function. Can you tell me how can we use applymap here.

sunny_talwar

Here you go

MappingLoad:

Mapping

LOAD * INLINE [

    F1, F2

    High, 3

    Med, 2

    Low, 1

];


Table:

LOAD RowNo() as RowNum,

[Initial Severity],

[Latest Severity],

If([Latest Severity Rank] > [Initial Severity Rank], [Latest Severity], 'N/A') as [New Severity];

LOAD *,

ApplyMap('MappingLoad', [Initial Severity], Null()) as [Initial Severity Rank],

ApplyMap('MappingLoad', [Latest Severity], Null()) as [Latest Severity Rank];

LOAD * INLINE [

    Initial Severity, Latest Severity

    High, Low

    Low, Med

    Med, High

    High, Low

    Med, High

    Low, High

    Med, Low

    High, Med

    Low, Med

];

durgabhavani
Creator III
Creator III
Author

Thank you very much sunny. I will try this.

sunny_talwar

Not sure if this will not cause the same issue as the other solution.... it is essentially doing the same thing

durgabhavani
Creator III
Creator III
Author

Thanks sunny. Applymap can be used perfectly with existing code and able to get expected output.