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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

AGGR() Question

Challenge:  Compare ABC item price  (lowest price) against all competitors.   Show only  records where ABC items (lowest priced item) is greater than ANY competitors's price (also lowest)

Dimensions:

Date, Competitors, Stores, Rtype

Competitors:

ABC, DEF, 123, 456

Stores:  Store descriptions are the same on all competitors.

Items: Items descriptions are not the same on all competitors.

Metric:

Min(
aggr(
sum({<Competitor={"=min(aggr(sum({<Competitor ={'ABC'}>}PRICE),DepDate,Competitor,Stores,RTYPE)) >
                    min(aggr(sum({<Competitor-={'ABC'}>}PRICE),DepDate,Competitor,Stores,RTYPE))"},Competitor={"*"}>}
                  PRICE)
,DepDate,Competitor,Stores,RTYPE)
)

This seems to work except when there are more than one RTYPE records.  It seems like it's summing all the RTYPE prices instead of using just the lowest price.  "High Park" and "Almond" are multi records.  I meant to compare it with only the lowest, not the sum of all RTYPE.

High Park SUM(PRICE) is equal to 27,000.    the min() = 1541

Almond SUM(PRICE) = 15,000 min() = 2131

DepDateStoresCompetitorABCDEF123456
07/01/2017High Park 1541--2066
07/01/2017Quiapo Store--1365.32-
07/01/2017Tres Amigo----
07/01/2017ADAGIO ACC----
07/01/2017PARIS VILLAGE----
07/01/2017PARIS MONTMARTRE----
07/01/2017BEACH AND WELLNESS RESORT5656--
07/01/2017RITMO CANADA5226--
07/01/2017ALMOND 2131--2651
07/01/2017CAP CAN 36483268--

Any idea what I'm missing?

3 Replies
Digvijay_Singh

I don't see RTYPE dimension values in your shared data, since you have used all four dimensions, just wondering what this data means, is this the output of your straight table?

Not applicable
Author

This is the expanded all.  Rtype: View 4 is the MIN() = 1541 and Flower View mn() = 2131.

     

DateHotelRTYPECompetitorABCDEF123456
07/01/2017High ParkVew 1 3791---
07/01/2017High ParkVew 2 1971---
07/01/2017High ParkVew 3 3201---
07/01/2017High ParkVew 4 1541---
07/01/2017High ParkVew 5 ---2066
07/01/2017High ParkVew 6 3381---
07/01/2017High ParkVew 7 1671---
07/01/2017High ParkVew 8 3201---
07/01/2017High ParkVew 9 3311---
07/01/2017High ParkVew 10 1621---
07/01/2017High ParkVew 11 3311---
07/01/2017Quiapo StorePenthouse---1365.32
07/01/2017BEACH AND WELLNESS RESORTType 1 5656---
07/01/2017RITMO CANADACoconut View5226---
07/01/2017ALMONDFlower View 1---2651
07/01/2017ALMONDFlower View 22291---
07/01/2017ALMONDFlower View 32131---
07/01/2017ALMONDFlower View 42581---
07/01/2017ALMONDFlower View 52581---
07/01/2017CAP CANARow 1 36483268--
Digvijay_Singh

Couldn't manage to correct your expression but it worked like below -

Capture.PNG

I added one more record through script to test one new case other than your data, it worked as desired.