Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem With nested if statement

Could someone help me out with the following. I am trying to get a table to show only products where the last order date is within a certain periond and where my current stock level is greater than a figure. I have two variables created, on for the stock level and one for the last order date. The if statement is: If(InStock>=InStockQuantity ,if(Max(LastOrderDate )>=Max(OrderDate),max(OrderDate))) .

This should show me the last order date but is shpwing nothing and i am confused! Thanks in advance

4 Replies
swuehl
MVP
MVP

Matt,

could you post a small sample here (upload is available from advanced editor)? This makes it much easier to see the context of your expression / issue. I assume that you get a problem because you use different levels of aggregation in your if-expression (record level and agreggated to dimension level), but I am just guessing right now (also, we need to know about the variables you are using).

Regards,

Stefan

Not applicable
Author

Hi Stefan

This is the full expression as copied from the editor:

if(InStock>=InStockQuantity, if(max(OrderDate)<=LastOrderDate,if(CostCalc='FOB',Sum(FOBCost*InStock),Sum(Cost *InStock))))

I seem to have fixed the problem by changing the chart type from pivot table to flat table, although why this should calculate the expression properly i am not sure.

The variables are LastOrderDate, InStockQuantity and CostCalc.

Matt

swuehl
MVP
MVP

I am also not sure why the chart type would affect the result in this case, I think it would be really helpful if you could post a (simplified) sample app here, if you need more help on this.

If not, have a nice weekend.

Regards,

Stefan

llauses243
Creator III
Creator III

Hi,

I estimate not necessary to use max(OrderDate), maybe be sufficient to use direct OrderDate

Good luck, Luis