Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
Luminary
Luminary

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
Highlighted
Partner
Partner

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.

Highlighted
Not applicable

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?

Highlighted
Luminary
Luminary

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

Highlighted
Not applicable

Thanks!