Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Edit Record on QVD

Guys, I need your help..

How to write script for edit record on QVD?

for example:

Update table_a

set Map_2='Other'

where Map_2='Opex'

Thank before.

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this

Table_a:

Load

Cost_Centre, Periode_Report, Amount,

if(match(Periode_Report,'201311','201312','201401','201402','201403')

     and Match(Cost_Centre,'S812','S813')

     and Map_1 <> 'Expense'), 'Other',Map_1) as Map_1,

if(Match(Periode_Report,'201311','201312','201401','201402','201403')

     and Match(Cost_Centre,'S812','S813')

     and Match(Map_2, 'OPEX'), 'Other OPEX',Map_2) as Map_2

Regards,

jagan.

View solution in original post

15 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

You cannot directly update a QVD instead you need to recreate it again like this

Data:

LOAD

Field1,

Field2,

If(Map_2 = 'Opex', 'Other', Map_2) AS Map_2

FROM QVDFileName.qvd;

STORE Data INTO QVDFileName.qvd;

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

Hi Valdi, there is direct way to edit the record in the QVD.

First you have to load the QVD and edit the record withe ApplyMap or LookUp or If condition. I personally use ApplyMap because its relatively very fast.

First create the Mapping Table with your edit field values.

MAP_EDIT:

MAPPING LOAD * INLINE [

Map_2, Map_2_New

Opex, Other

Opex1, Other1

];

QVDNAME:

LOAD A, B, C, ApplyMap('MAP_EDIT', Map_2 , Map_2) AS Map_2

From QVDNAME.qvd (qvd);

STORE QVDNAME into QVDNAME.qvd (qvd) ;

DROP Table QVDNAME ;

Not applicable
Author

how to edit record for example:

Data:

LOAD

Field1,

Field2,

If(Map_2='OPEX','OTHER',MAP_2) as MAP_2

from QVDFileName.qvd

store Data into QVDFileName.qvd

and I want to keep data 2013, and just data 2014 has changed?

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Data:

LOAD

Field1,

Field2,

If(Year(DateFieldName) = Year(Today()) AND Map_2 = 'Opex', 'Other', Map_2) AS Map_2

FROM QVDFileName.qvd;

STORE Data INTO QVDFileName.qvd;

Replace DateFieldName with your date field name.

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

Can You give me write example Year Date?

Data:

Load

Field1, Field2, If (Year(DatePeriode_Report)=Year(Today())) and Map_2='Opex','Other',Map_2) as Map_2 ?

Record Periode Report='2013011','2013012','2014001','2014002','2014003'

how to write the scrip for YearDate?

jagan
Luminary Alumni
Luminary Alumni

Hi,

Can you attach some sample data and expected output?  or try this

Load

Field1, Field2, If (Left(DatePeriode_Report, 4)=Year(Today())) and Map_2='Opex','Other',Map_2) as Map_2

FROM QVDFileName.qvd;

STORE Data INTO QVDFileName.qvd;

Regards,

Jagan.

Not applicable
Author

Great,

Thank you Mr.Jagan Mohan.

Regards.

jagan
Luminary Alumni
Luminary Alumni

Hi,

Please close this thread by clicking Correct and Helpful Answer  buttons to the posts.  It helps others in finding the answers for similar requirement.

Regards,

Jagan.

Not applicable
Author

Mr. Jagan,

I'm sorry, I have the last question. how to write script if

Map_3=('Depreciation','Fixed Assets','GA Exp'),'Other',Map_3) as Map_3?  <<-- is it true?

I want to edit 3 differrent record ('Depreciation','Fixed Assets','GA Exp') to 'Other' furthermore Map_3

Thanks before.