4 Replies Latest reply: May 21, 2012 6:51 AM by Marco De

# if condition in min value

Hi all
I have to calculate the min value of the size "sales".
I know that the syntax is: min(sales)
Before calculating the min I have to normalize the format of the sale's values. For do this I use this:
if(sales<100, sales,
if(sales>100 and sales<10000, sales/100,
if(sales>10000, sales/1000)))
Now how can I calculate the min of the value "sales" determined in the if condition?

Thanks
• ###### Re: if condition in min value

Hello,

Main:

if(sales<100, sales,

if(sales>100 and sales<10000, sales/100,

if(sales>10000, sales/1000))) as TempSales

From Table;

Resident Main;

Hope it hepls you.

• ###### if condition in min value

But i have to do this in the script?

There isn't a way to do it in the expression editor of the chart where i have to calculate the min?

• ###### if condition in min value

Can't you just wrap the whole expression in Min()?

Min(

if(sales<100, sales,

if(sales>100 and sales<10000, sales/100,

if(sales>10000, sales/1000)))

)

Although I would probably recommend that in the script you define a factor and use this instead of the nested IF in the UI:

Sales:

*,

if(sales<100, 1,

if(sales>100 and sales<10000, 100,

if(sales>10000, 1000)))     AS     SalesFactor

FROM....;

Then, in the UI:

Min(Sales/SalesFactor)

Hope this helps,

Jason

• ###### if condition in min value

Thanks!