# New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Highlighted
New Contributor II

## sum problem with pivot table

Hello,

I have this table:

 COMMERCIAL Emploi PRODUITS REALISATION score SCORE_AVEC_PLAFOND 001 CCPP x1 331568 66314 1667 x2 84576 42288 1667 416144 66314 66314 002 CCPP x2 4752 950 950 x3 260579 130289 1667 265331 950 950

I have a problem with the sum here.

Can you explain why I got this mistake?

and anyone that can help me to resolve this issue please?

Thanks

Regards,

1 Solution

Accepted Solutions
Highlighted
MVP

## Re: sum problem with pivot table

May be try this

score=

Sum(Aggr(

if(

if(IsNull(score_periode1), sum(score_periode2*VALEUR),sum(score_periode1*VALEUR))

<0,

0,

if(IsNull(score_periode1), sum(score_periode2*VALEUR),sum(score_periode1*VALEUR))

)

, COMMERCIAL, Emploi, PRODUITS))

SCORE_AVEC_PLAFOND=

Sum(Aggr(

if(match(REF,'19.1','377')   and

Sum(Aggr(

if(

if(IsNull(score_periode1), sum(score_periode2*VALEUR),sum(score_periode1*VALEUR))

<0,

0,

if(IsNull(score_periode1), sum(score_periode2*VALEUR),sum(score_periode1*VALEUR))

)

, COMMERCIAL, Emploi, PRODUITS))

>2000*(5/6),  2000*(5/6),

Sum(Aggr(

if(

if(IsNull(score_periode1), sum(score_periode2*VALEUR),sum(score_periode1*VALEUR))

<0,

0,

if(IsNull(score_periode1), sum(score_periode2*VALEUR),sum(score_periode1*VALEUR))

)

, COMMERCIAL, Emploi, PRODUITS))

)

, COMMERCIAL, Emploi, PRODUITS))

8 Replies
Highlighted
MVP

## Re: sum problem with pivot table

What is the expression that you are using?

Highlighted
New Contributor II

## Re: sum problem with pivot table

REALISATION= sum(VALEUR)

score=

if(

if(IsNull(score_periode1), sum(score_periode2*VALEUR),sum(score_periode1*VALEUR))

<0,

0,

if(IsNull(score_periode1), sum(score_periode2*VALEUR),sum(score_periode1*VALEUR))

)

SCORE_AVEC_PLAFOND=

if(match(REF,'19.1','377')   and   score>2000*(5/6),  2000*(5/6),   score)

Highlighted
MVP

## Re: sum problem with pivot table

May be try this

score=

Sum(Aggr(

if(

if(IsNull(score_periode1), sum(score_periode2*VALEUR),sum(score_periode1*VALEUR))

<0,

0,

if(IsNull(score_periode1), sum(score_periode2*VALEUR),sum(score_periode1*VALEUR))

)

, COMMERCIAL, Emploi, PRODUITS))

SCORE_AVEC_PLAFOND=

Sum(Aggr(

if(match(REF,'19.1','377')   and

Sum(Aggr(

if(

if(IsNull(score_periode1), sum(score_periode2*VALEUR),sum(score_periode1*VALEUR))

<0,

0,

if(IsNull(score_periode1), sum(score_periode2*VALEUR),sum(score_periode1*VALEUR))

)

, COMMERCIAL, Emploi, PRODUITS))

>2000*(5/6),  2000*(5/6),

Sum(Aggr(

if(

if(IsNull(score_periode1), sum(score_periode2*VALEUR),sum(score_periode1*VALEUR))

<0,

0,

if(IsNull(score_periode1), sum(score_periode2*VALEUR),sum(score_periode1*VALEUR))

)

, COMMERCIAL, Emploi, PRODUITS))

)

, COMMERCIAL, Emploi, PRODUITS))

Highlighted
New Contributor II

## Re: sum problem with pivot table

excellent bro. thanks a lot

Highlighted
Esteemed Contributor III

## Re: sum problem with pivot table

Can we write this way sunny?

score=

Sum(Alt(score_periode1, scoreperiode2)*VALEUR)

SCORE_AVEC_PLAFOND=

if(match(REF,'19.1','377')   and   Sum(Alt(score_periode1, scoreperiode2)*VALEUR)  > 2000*(5/6),  2000*(5/6),   Sum(Alt(score_periode1, scoreperiode2)*VALEUR))

Highlighted
MVP

## Re: sum problem with pivot table

I think there is a check for less than 0 also... may be like this

Sum(Aggr(RangeMax(Sum(Alt(score_periode1, scoreperiode2)*VALEUR), 0), COMMERCIAL, Emploi, PRODUITS))

Highlighted
Esteemed Contributor III

## Re: sum problem with pivot table

Hey Amine,

can you also try this and let us know if this works too?

score=

Sum(Aggr(RangeMax(Sum(Alt(score_periode1, scoreperiode2)*VALEUR), 0), COMMERCIAL, Emploi, PRODUITS))

SCORE_AVEC_PLAFOND=

Sum(Aggr(

if(match(REF,'19.1','377')   and

Sum(Aggr(RangeMax(Sum(Alt(score_periode1, scoreperiode2)*VALEUR), 0), COMMERCIAL, Emploi, PRODUITS)) > 2000*(5/6),  2000*(5/6),

Sum(Aggr(RangeMax(Sum(Alt(score_periode1, scoreperiode2)*VALEUR), 0), COMMERCIAL, Emploi, PRODUITS))

)

, COMMERCIAL, Emploi, PRODUITS))

Highlighted
Esteemed Contributor III

## Re: sum problem with pivot table

Oh i missed that. Got it. Thank you.