Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Community,
I appreciate any assistance with this IF statement that has been bugging me for a while now. I'm pretty new to this piece of QV and thank you in advance for any guidance.
IF ([Order Status]='Open' and [Order Date] <=Today-7,'0-7 Days', IF [Order Date] >Today-8<15, '8-14 Days', IF [Order Date]>Today-15<22,'15-21 Days', IF [Order Date] >Today-21 '22+Days')
Cheers!
Sharon
Try this. I used two intersections because your comparison is based on two fields: order status and order date.
IF([Order Status]='Open',
IF([Order Date] <= (Today()-7),'0-7 Days',
IF ([Order Date] > (Today()-8) AND [Order Date]<(Today()-15), '8-14 Days',
IF ([Order Date]>(Today()-15) AND [Order Date]<(Today()-22),'15-21 Days'))),
IF ([Order Date] >Today()-21,'22+Days'))
If you are doing this in a script you have to close all of the if statements and name your field. Also I would just nest the if statement again and not use the AND at the beginning. For example:
IF ([Order Status]='Open',
IF([Order Date] <=Today-7,'0-7 Days',
IF ([Order Date] >Today-8<15, '8-14 Days',
IF ([Order Date]>Today-15<22,'15-21 Days',
IF ([Order Date] >Today-21 '22+Days'))))) as OrderDateBuckets
Every IF has it's own set of parenthesis at the beginning and then they all close at the end.
Also you syntax for the today command should be Today()-7, You may even want to put it in parenthesis like so (Today()-7)
Hi,
Can you plese post your sample file
You are almost there
IF ([Order Status]='Open' and [Order Date] <=(Today()-7),'0-7 Days', IF([Order Date] >(Today()-8<15), '8-14 Days', IF( [Order Date]>(Today()-15)<22,'15-21 Days', IF( [Order Date] >(Today()-21), '22+Days'))))
Braces for if if stetement and added () to Today().
Thanks,
Rajesh Vaswani
Hi,
Try this, missed brackets for Today
IF ([Order Status]='Open',
IF([Order Date] <=Today()-7,'0-7 Days',
IF ([Order Date] >Today()-8 AND [Order Date]<Today()-15, '8-14 Days',
IF ([Order Date]>Today()-15 AND [Order Date]<Today()-22,'15-21 Days',
IF ([Order Date] >Today()-21, '22+Days'))))) as OrderDateBuckets
jpapdor,
I appreciate your help and guidance in re: to the ()'s. I did add them after Today and additionally put the Today-7 in parens; sadly I am still receiving an error in my expression. Am still trying to tweak and with your assistance feel I am much closer. Thank you!
Amuthabharathi,
I am unable to post a sample file due to confidentiality. I'm sorry. Thanks for your willingness to assist!
Are you trying to do this in an expression in a chart or in the script editor?
Rajesh,
This was definitely helpful but am still getting an error in the expression. I think with your help and the other comments here that I am much closer. i'll continue to work with it and let you know what works in the end. Thanks so much!
Jpapdor,
i am adding this into an expression for a chart.