Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Max value of an if statement

Hi all,

I have an expression with an if statement and multiple dimensions which shows me the amount of days the payment of an outstanding invoice was due. I have two created Variables (Begin and End) in a slider/input box.

=if

(sum({<Year=,Month=>} OutstandingAmount)<>0 AND (today() - only(InvoiceExpirationDate)>0),

(today() - only(InvoiceExpirationDate)))

This works fine, but how can I calculate the Max value of this function?

Name X, oldest invoice = xx/xx/xx, this = 100 days

Name Y, oldest invoice = xx/xx/xx, this = 50 days

Name Z, oldest invoice = xx/xx/xx, this = 30 days

I should get the result:

Name X, 100 days

Can anybody help me?

Thanks in advance

6 Replies
sdmech81
Specialist
Specialist

HI,If expression is correct then Max (Your expression  )  should give 100 I guess..

if u want Name then just try something like:

=Firstsortedvalue(Name,-Your expression)..

Try like this it should work:)

Sachin

sasikanth
Master
Master

Try like below

At script level:

Load

Name,

OldInvoicedate,

Interval(Today()-OldInvoicedate,'DD') AS No.ofDays

FROM table1;


Now if you want to display Name then use this

FirstSortedValue(Name,-Aggr(sum(No.ofDays),Name))

Not applicable
Author

No it does not. Just putting Max() around it gives me an "Error in expression" in the expression window...

sasikanth
Master
Master

Or Try This,

FirstSortedValue(

     Name,

           -Aggr( IF( (sum({<Year=,Month=>} OutstandingAmount)) <>0

               AND  (Interval(today() - InvoiceExpirationDate ,'DD')>0), Interval(today() - InvoiceExpirationDate ,'DD')                   )),Name)

)

Not applicable
Author

Is there an option without having to touch the script? I am not allowed to change anything in the script...

sasikanth
Master
Master

Please share your application, the above expression you can write only in charts not in Script