# Qlik Sense App Development

Announcements
BARC’s The BI Survey 19 makes it official. BI users love Qlik. GET REPORT
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.

 Provider Product Lowest price #Product at the lowest price ZeCompany Bear = min(Price) = sum(if(Price=min(Price), 1, 0)) OtherCompany Bear = 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?

1 Solution

Accepted Solutions MVP

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

Try like:

`Sum(if(Price=Aggr(NODISTINCT Min( Price),Provider), 1,0))`
5 Replies
Valued Contributor

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

Hi

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

New Contributor II

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

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.

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

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

Try like:

`Sum(if(Price=Aggr(NODISTINCT Min( Price),Provider), 1,0))`
New Contributor II

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

Great! Thank you.

I forgot NODISTINCT.