Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
BARC’s The BI Survey 19 makes it official. BI users love Qlik. GET REPORT
adelmeire
New Contributor II

Error with expression : sum(if(Price=min(Price), 1, 0))

Hi everybody,

I need some help for the expression of the last column.

ProviderProductLowest price#Product at the lowest price
ZeCompanyBear= min(Price)= sum(if(Price=min(Price), 1, 0))
OtherCompanyBear= min(Price)= sum(if(Price=min(Price), 1, 0))

 

A product has a price which change during the year, for example. For each provider, I'ld to know what is the lowest price (=min(Price), it's ok) and how many bears has been sold at this price (= sum(if(Price=min(Price), 1, 0)) but it doesn't work)

Does anyone has an idea how to write this expression?

Thank you for your help

 

1 Solution

Accepted Solutions
MVP
MVP

Re: Error with expression : sum(if(Price=min(Price), 1, 0))

Try like:

Sum(if(Price=Aggr(NODISTINCT Min( Price),Provider), 1,0))

View solution in original post

5 Replies
Shubham_Deshmukh
Valued Contributor

Re: Error with expression : sum(if(Price=min(Price), 1, 0))

Hi Adelmeire,

As per my understanding from your data, you want count of all Bears sold at min price.

Create variable : vMinPrice = min(Price)

Use exp : 

=Count(if(Price=vMinPrice,1))

Rather than using '1', if you have any ID corresponding to that product then it would be better to use.

Regards

adelmeire
New Contributor II

Re: Error with expression : sum(if(Price=min(Price), 1, 0))

Thank you for your reply Shubham.

I think your solution won't works, because the variable will calculate the min(Price) for all providers.

Here, I want to count how many products, for each provider, has been sold at the min price of this provider.

Shubham_Deshmukh
Valued Contributor

Re: Error with expression : sum(if(Price=min(Price), 1, 0))

Ohh..My bad...my solution will give overall count not provider wise.
Can you share sample data?
MVP
MVP

Re: Error with expression : sum(if(Price=min(Price), 1, 0))

Try like:

Sum(if(Price=Aggr(NODISTINCT Min( Price),Provider), 1,0))

View solution in original post

adelmeire
New Contributor II

Re: Error with expression : sum(if(Price=min(Price), 1, 0))

Great! Thank you.

I forgot NODISTINCT.