Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

SUM duplicates in Load Script

Hello,

I have a problem in loading script. I don´t know what is wrong.

In a QVD file with several columns I want to apply SUM function.

let´s say:

Year   Product     PRV     Amount

2014   prdA          A          24720

2014   prdB          A          24720

I do apply SUM function like this:

FINAL_QVD:

load PRV,SUM(Amount) as SAmount from QVD.qvd (qvd)

group by PRV;

Finally, when I create a Table from FINAL_QVD I get this:

PRV     SAmount

A          98880


Instead of:

PRV     SAmount

A          49440

1 Solution

Accepted Solutions
marcus_malinow
Valued Contributor III

Re: SUM duplicates in Load Script

Diego,

it's going to be difficult to work out what's going on here, but it certainly looks like you have duplicates.

You could try adding count(Amount) to see if this is the case.

I'd suggest that you need to look at the code that's creating your original QVD.

Marcus

2 Replies
marcus_malinow
Valued Contributor III

Re: SUM duplicates in Load Script

Diego,

it's going to be difficult to work out what's going on here, but it certainly looks like you have duplicates.

You could try adding count(Amount) to see if this is the case.

I'd suggest that you need to look at the code that's creating your original QVD.

Marcus

ramoncova06
Valued Contributor III

Re: SUM duplicates in Load Script

the distinct field is product, so either you add it as part of your group or you apply a distinct to your sum

FINAL_QVD:

load distinct PRV,SUM(Amount) as SAmount from QVD.qvd (qvd)

group by PRV;