Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Solving function

Hi everyone,

I do need a hand to solve this formula:

Sum(aggr(avg({$<[Type]={0}>}Price*Sum (Qty)),ItemNumber, Type, ))

Thanks a lot

19 Replies
passionate
Specialist
Specialist

Hi Florian,

Please provide some sample data.

In below formula you only want to add a set analysis modifier i.e Type=0 ?

Sum(aggr(avg(Price)*sum(Quantity),ItemNumber, Type))


Regards,

Pankaj

passionate
Specialist
Specialist

Hi Florian,

Try using below expression:

=Sum(aggr(avg({<Type={'0'}>}Price)*sum({<Type={'0'}>}Qty),ItemNumber, Type))

Regards,

Pankaj

Not applicable
Author

Hi Pankaj,

Yes That's what i'm trying to do but I don't understand why it doesn't work out.

The correct answer is 53.07 (Qlik Sense with filter: year=2017 and type=0) and while using my function I get 11.45 (filter: year=2017)

It's quite hard to provide you with some data because they are confidential.

Best,

Florian

passionate
Specialist
Specialist

Hi Florian,

I have attached a QVW please check if this is what you want.

Regards,

Pankaj

Not applicable
Author

!Hi Pankaj, !

I had to log out and log in again to see your file.

I would need to get 3875 for your example.

         

ItemNumberPriceQtyTypeTotal costItemNumberAVG(Price)Total
1100101001181.8182CHF 182
1100303002468.75CHF 545
1200102003172.2222CHF 182
1200408004392.8571CHF 727
130020600CHF 364
210040400CHF 1 875
KPI ValueCHF 3 875

Firstly, I have calculated the weighted price in the AVG(Price) column and then I have multiplied the quantity corresponding to 0 type with this weighted price to get CHF 3875.-

Let me know if it's not clear.

Best,

Florian

balar025
Creator III
Creator III

Hi Florian,

Please share your sample data with your expected output to better understand your query .

sunny_talwar

Everything in your chart seems to be Type 0? Is that a typo?

Not applicable
Author

I added a filter for the type in Excel.

If I refer to the data given by Pankaj I would like to get this:

         

ItemNumberPriceQtyTypeTotal costItemNumberAVG(Price)Total
1100101001181.8182CHF 182
1100303002468.75CHF 545
1200102003172.2222CHF 182
1200408004392.8571CHF 727
130020600
CHF 364
210021200
210040400
CHF 1 875
210051500
220021400
22000316000KPI ValueCHF 3 875
310042400
310052500
3200521000
3300411200
410023200
410032300
410043400
420033600
42000224000
sunny_talwar

But how are you getting the values for TOTAL column? Can you share an excel file showing the calculation used here?

Not applicable
Author

We do have 6 items with type = 0 which should appear in my answer and they are displayed within the total column.

Type, Qty, AVG(Price), Total (Qty*Price)

1 ,1, 181.8182, 182

1, 3, 181.8182, 545

1, 1, 181.8182, 182

1, 4, 181.8182, 727

1, 2, 181.8182, 364

2, 4, 468.75, 1875

Best,

Florian