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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Min/Max Function

I am facing issues with Min/Max function. There are two date fields Claim_Date and Paid_Date. I want to find the difference in years which I am able to do with the following:

Year(Paid_Date) - Year(Claim_Date) as Lag_years

This works in the scrip editor.

To avoid data errors I want to limit it to minimum 0 and maximum 5. In Excel or SQL this would be simply as follows:

Min(5,Max(0,Year(Paid_Date) - Year(Claim_Date)))

However, neither the minimum or maximum function are working. I have even tried the following in Expression in the pivot table:

Min(5,Max(0,Lag_Years))

Is there any special way of using Min/Max in Qlikview.

Thanks.

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You can use the rangemax and rangemin functions here:

rangemin(5,rangemax(0,Year(Paid_Date) - Year(Claim_Date))) as Lag_years


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
tresesco
MVP
MVP

you can try something like:

If( (Year(Paid_Date) - Year(Claim_Date))>=5, 5,

      If((Year(Paid_Date) - Year(Claim_Date))<0, 0, (Year(Paid_Date) - Year(Claim_Date)))) as Lag_years   

Thanks.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You can use the rangemax and rangemin functions here:

rangemin(5,rangemax(0,Year(Paid_Date) - Year(Claim_Date))) as Lag_years


talk is cheap, supply exceeds demand