Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Field to Column Ref & Update

Hi,

I am currently trying to restructure data based upon a column where the fields give a reference to another column along with the value that needs to change.

The raw data looks like this (shrunk down and restructed to 1 Ref):

RefA1A2A3A4A5DATETIMENEWOLDFIELDORDER
98763325.50186319001679.8516/04/201312:306137.000A21
98763325.50186319001679.8515/11/201309:2311250.506137.00A22
98763325.50186319001679.8515/11/201309:2318630A33
98763325.50186319001679.8515/11/201309:231679.850A54
98763325.50186319001679.8520/11/201312:103325.5011250.50A25
98763325.50186319001679.8520/11/201312:1019000A46
98763325.50186319001679.8507/02/201413:0903325.50A27
98763325.50186319001679.8507/02/201413:093325.500A18

A1 - A5 shows current data.  FILED refers to the field that needs to be changed and NEW and OLD refers to the new and old values.

The output should look like this:

RefNA1NA2NA3NA4NA5NDATENTIMENNEWNOLDNFIELDNORDERN
98760613700016/04/201312:306137.000A2N1
9876011250.500015/11/201309:2311250.506137.00A2N2
9876011250.518630015/11/201309:2318630A3N3
9876011250.5186301679.8515/11/201309:231679.850A5N4
987603325.5186301679.8520/11/201312:103325.5011250.50A2N5
987603325.5186319001679.8520/11/201312:1019000A4N6
987600186319001679.8507/02/201413:0903325.50A2N7
98763325.50186319001679.8507/02/201413:093325.500A1N8

I'm not too sure on the best way to achieve this, I was thinking about grouping and using long 'if' statements in the load script but im realy not convinced this is the best way.

Do anyone have ideas on the best way?

Thanks in advance.

1 Solution

Accepted Solutions
Gysbert_Wassenaar

I think you probably need to make sure your data is sorted by Ref first and ORDERN second. Or maybe Ref, DATEN and TIMEN. And you might need a check to see you're dealing with the same Ref.

Change

     if(FIELD='A1',NEW,alt(peek('A1'),0)) as A1

to

     if(FIELD='A1',NEW, if(Ref=previous(Ref),peek('A1'),0)) as A1,

And the same for the other A- fields.


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar

See attached qvw


talk is cheap, supply exceeds demand
Not applicable
Author

Thank you Gysbert, that looks perfect for what I am after.  Will now try to apply to the large dataset.

Thanks again.

Not applicable
Author

Hi Gysbert,

I have applied the method to my main application.  It works if I restrict the application to one reference number however if I use the mass data the results are mixed up.  I have thought about using a Group By function however it doesnt seem to work.

Any ideas?

Thanks

Gysbert_Wassenaar

I think you probably need to make sure your data is sorted by Ref first and ORDERN second. Or maybe Ref, DATEN and TIMEN. And you might need a check to see you're dealing with the same Ref.

Change

     if(FIELD='A1',NEW,alt(peek('A1'),0)) as A1

to

     if(FIELD='A1',NEW, if(Ref=previous(Ref),peek('A1'),0)) as A1,

And the same for the other A- fields.


talk is cheap, supply exceeds demand