Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
My current code is as below:-
Sum(if(date(date#([WO created date],'YYYYMMDD'),'YYYYMMDD')
>
date(AddYears(date#(warrantydate,'YYYYMMDD'),1),'YYYYMMDD'),[Count WO],0))
which gives me values in number.
Now I have to insert additional conditional check in this code as :- [WO task code id]*={'T113','T114'}
How can I acheive this.
Thanks
Try like:
Sum( {<[WO task code id]*={'T113', 'T114'}>} if(date#([WO created date],'YYYYMMDD')> AddYears(date#(warrantydate,'YYYYMMDD'),1),[Count WO],0))
Note: removed unnecessary formatting function date()
I think I would convert all dates-fields already within the script into real dates (maybe as additionally fields and if needed within an own calendar) so that no convertings within any UI calculations are neeeded. Further like Tresesco already mentioned for a numerical comparing is no formatting necessary.
Depending on your datamodel you might be also able to transfer the if-loop into the set analysis which then might be look like:
Sum({<[WO task code id]*={'T113', 'T114'},
[Count WO] = {"=[WO created date]>AddYears(warrantydate,1)"}>} [Count WO])
Should this not be possible it's often better to use a: if(condition, sum(field)) instead of sum(if(condition, field)) for performance reasons.
- Marcus