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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Expression Question

I have the following expression and it doesn't appear to be working can anyone help me with the correct syntax????

Sum({$<[Invoice Date] <= {$(AsofDate)}> + <{$(AsofDate) - num(Due Date) >= 1 and $(AsofDate) <= 10}>} [Balance in Home Currency])

I am basically trying to put together two if conditions in set expression

if invoice date <= AsOfDate (which is a variable in MM/DD/YYYY format)

and if the AsOfDate - Due Date >= 1 and AsOfDate - Due Date <= 10

then sum(balance in home currency)

Do I have to do any formatting for AsOfDate????

5 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

This part isn't valid: <{$(AsofDate) - num(Due Date) >= 1 and $(AsofDate) <= 10}> . A set modifier needs a field name on the left side of the comparison not an expression. If Due Date is a field you could try <[Due Date] = {'=$(AsofDate) - num([Due Date]) >= 1 and $(AsofDate) <= 10'}>. Somehow I doubt it'll do what you want. You should probably try an if statement instead.


talk is cheap, supply exceeds demand
Not applicable
Author

I have tried this if condition but can't get it to work right:

Sum(if([Invoice Date] <= date(AsOfDate,'MM/DD/YYYY') and (num(AsOfDate) - num([Due Date]) >= 1 and num(AsofDate) - num([Due Date]) <= 10), [Balance in Home Currency]))

I managed to get this to work but when I add the additional 'and' statement I don't get anything:

Sum(if([Invoice Date] <= date(AsOfDate, 'MM/DD/YYYY'),[Balance in Home Currency]))

Brice-SACCUCCI
Employee
Employee

What about the following?

Sum(if([Invoice Date] <= date(AsOfDate,'MM/DD/YYYY')

          and (num(date(AsOfDate,'MM/DD/YYYY')) - num([Due Date]) >= 1

          and num(date(AsOfDate,'MM/DD/YYYY')) - num([Due Date]) <= 10), [Balance in Home Currency]))

Not applicable
Author

It looks like this works!!!!

Thank you so much!!!

Brice-SACCUCCI
Employee
Employee

Nice! Can you mark the question as solved?

Thanks,

Brice