Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Conditional renaming of data, is it possible?

Hi,

I have a file of logged stopreasons for a machine. Every stop reason has a stop code.

I have a problem that some of the stop codes are not logged correctly by the operator.

I can filter out this incorrect data by comparing to other fields in the data, for example:

I know that code 100 cannot occur in machine A during setup (where machine A is under the machine column and setup is under the operation column), instead this should be code 200.

Is it possible to have qlikview change the stop code if certain conditions are fulfilled? Maybe in the script?

Hope you can understand my question=)

Thanks

Johan

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hello Johan,

If you know the correspondence between machines you can use something like the following

CorrectionMachineOperationandCodeMap:MAPPING LOAD * INLINE [MachineOperation, CorrectedCodeASetup, 200]; Original:LOAD Ceil(Rand() * 3) * 100 AS Code, Pick(Ceil(Rand() * 3), 'Setup', 'Run', 'Stop') AS Operation, Chr(64 + Ceil(Rand() * 5)) AS MachineAUTOGENERATE 100; Corrected:LOAD Code, Operation, Machine, ApplyMap('CorrectionMachineOperationandCodeMap', Machine & Operation, Code) AS CorrectedCode // Wil return the original if there's no correspondenceRESIDENT Original; DROP TABLE Original;


Hope that helps

View solution in original post

3 Replies
Not applicable
Author

Hi

You can try this in the script

If(Code=100 and Machine='A' and operation = 'Setup',200,Code) as Code,

Regards

Anders

Miguel_Angel_Baeyens

Hello Johan,

If you know the correspondence between machines you can use something like the following

CorrectionMachineOperationandCodeMap:MAPPING LOAD * INLINE [MachineOperation, CorrectedCodeASetup, 200]; Original:LOAD Ceil(Rand() * 3) * 100 AS Code, Pick(Ceil(Rand() * 3), 'Setup', 'Run', 'Stop') AS Operation, Chr(64 + Ceil(Rand() * 5)) AS MachineAUTOGENERATE 100; Corrected:LOAD Code, Operation, Machine, ApplyMap('CorrectionMachineOperationandCodeMap', Machine & Operation, Code) AS CorrectedCode // Wil return the original if there's no correspondenceRESIDENT Original; DROP TABLE Original;


Hope that helps

Not applicable
Author

Thank you Miguel!

It works really good!

//

Johan