19 Replies Latest reply: Mar 7, 2018 7:59 AM by Sunny Talwar

# KPI Sum expression problem

Hi

I try to make a KPI that calculate total cost for rearing a car

The data are spreed in several spread sheets.

In sheet 1 I have

Repair no                    Part changed

1                                   Tires

2                                   Engine

3                                   Screw

4                                   Tires

5                                   Screw

In sheet 2 I have

Part changed          Price

Tires                         100

Engine                      8100

Screw                       1

Front glass               300

I tried with this expression

Sum([Price]*Count([Repair no]))

But it doesnt work, can you give me a hint whats wrong?

Thanks,

Peter

• ###### Re: KPI Sum expression problem

May be this

Sum([Price])*Count([Repair no])

• ###### Re: KPI Sum expression problem

check this out.you forgot to aggregate with respect to each and every part changed for both sum and count.

• ###### Re: KPI Sum expression problem

Hi,

When I use Sum([Price])*Count([Repair no]) I get a wired number

Krishna what expression did you use?

• ###### Re: KPI Sum expression problem

= sum({\$< [Part changed]={'Engine'}> }Price)* count({\$< [Part changed]={'Engine'}> }[Part changed]) +

sum({\$< [Part changed]={'Tires'}> }Price) * count({\$< [Part changed]={'Tires'}> }[Part changed]) +

sum({\$< [Part changed]={'Screw'}> }Price)* count({\$< [Part changed]={'Screw'}> }[Part changed])

As you have different parts and each have respective counts and aggregation, the below expression yields wierd numbers.

Sum([Price])*Count([Repair no])

• ###### Re: KPI Sum expression problem

Thanks

What if the numbers of parts on the list is huge fx several hundreds, is there a better way to solve the issue?

• ###### Re: KPI Sum expression problem

You can try this

Sum(Aggr(Sum([Price])*Count([Repair no]), [Part changed]))

• ###### Re: KPI Sum expression problem

Still it doesnt calculate correct

• ###### Re: KPI Sum expression problem

Based on the sample provided... what is the correct output?

• ###### Re: KPI Sum expression problem

Is 8302 not the right number?

• ###### Re: KPI Sum expression problem

The correct number is 8302

I use the KPI chart, dont we agree that expression should be entered here under Expression?

• ###### Re: KPI Sum expression problem

The screenshot I posted was from QlikView... here is a Qlik Sense screenshot and sample

• ###### Re: KPI Sum expression problem

Where do you enter the formula?

Did you enter it under Expression?

• ###### Re: KPI Sum expression problem

Super, thanks a lot... I will investigate whats wrong with mine.

thanks a lot... I will close the ticket asap I have completed the investigation.

I hope its ok

• ###### Re: KPI Sum expression problem

Sure it is

• ###### Re: KPI Sum expression problem

See attached qvw

• ###### Re: KPI Sum expression problem

May be this Expected output-

• ###### Re: KPI Sum expression problem

Thanks all of you, it is solved with your input

• ###### Re: KPI Sum expression problem

Pls close the thread