Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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
1 Solution

Accepted Solutions
Jason_Michaelides
Luminary Alumni
Luminary Alumni

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:

LOAD

     *,

     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

View solution in original post

4 Replies
jagannalla
Partner - Specialist III
Partner - Specialist III

Hello,

Main:

Load *,

if(sales<100, sales,

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

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

From Table;

Load Min(TempSales) as MinSalesValue

Resident Main;

Hope it hepls you.

Not applicable
Author

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?

Jason_Michaelides
Luminary Alumni
Luminary Alumni

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:

LOAD

     *,

     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

Not applicable
Author

Thanks!