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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Min function

Hello,

I have a problem:

I have a table similiar to this example:

ArticlePriceQuantity
A50200
B60250
C70400
A100200
B95250
C120400

I need to calculate the average of the lower price * quantity.

I don't know how to select the lower price for each article, I tried with

avg (Quantity) *  Min (Price)

but Min (Price) is calculate over all entries, and not for every specific Article.

Please help me

1 Solution

Accepted Solutions
swuehl
MVP
MVP

So your QTY is alway the same for each Item Number?

Then you might try this:

=avg(aggr(min([Competitor Price])*only(QTY),[Item Number]))

Hope this helps,

Stefan

View solution in original post

7 Replies
jagannalla
Partner - Specialist III
Partner - Specialist III

Use the below script may be it helps you...

Table1:

Load

Article,

Price,

Quantity,

Price * Quantity as data,

from table1;

ResidentData:

Load Min(Data) as  LowerPrice

Resident Table1

Group By Article

;

Article

swuehl
MVP
MVP

Not sure that I understood your complete requirement.

The min Price grouped by Article could be found by

min(total<Article> Price)

I think, but then... what is the next step in your calculation, could you give an example calculation with above data?

edit: if you want to calculate that result outside of that table e.g. in a text box, you probably need advanced aggregation, aggr() function.

Not applicable
Author

This solution is not working.....

LowerPrice is incorrect (and i can't understand why.....)

Another problem is that quantity and price are not in the same table (now I'm trying your solution in a different table with both field).

I need to compare average prices of one company to average lowest price of the market.

So I'm looking for a solution to calculate correct "avg lowest price" for each article.

swuehl
MVP
MVP

Sorry, I am not familiar with avg lowest price.

Could you calculate an example with above table data for me/us?

Not applicable
Author

OK, here is one real example:

Item NumberQTYCompetitor PriceMy PriceCompetitor Pice * QTY
68682684256,5178,76175446
11348145142,599,366412,5
1134814518599,368325
131772 258192,5168,7349665
131772258206,5168,7353277

I need to calculate the average competitor lowest price of these products that is (175446+6412,5+49665)/3, but I don't know how

swuehl
MVP
MVP

So your QTY is alway the same for each Item Number?

Then you might try this:

=avg(aggr(min([Competitor Price])*only(QTY),[Item Number]))

Hope this helps,

Stefan

Not applicable
Author

It works, thank you !