web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Add a filter in where clause

(0) ShareShare
ReportReport
Posted on by

Hello, 


I would like to create a filter like below but I think substr method is not possible in the where clause. 

How can I manage it ? 

while select * from vendTrans
        join tri_NettingCorrelationAP
           where
              vendTrans.AccountNum == tri_NettingCorrelationAP.TRI_PurchAccount
              && (substr(vendTrans.Voucher,1,3) == "AFG" || substr(vendTrans.Voucher,1,2) == "FF" || substr(vendTrans.Voucher,1,3) == "AF")
              && vendTrans.createdDateTime >= this.dateCompare(SystemDateGet()-365)

Thanks

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    on at
    RE: Add a filter in where clause

    Hi mimi,

    If you want to use subStr, you can check into using if condition. Otherwise, you can try using like operator

  • Verified answer
    Martin Dráb Profile Picture
    on at
    RE: Add a filter in where clause

    Using 'like' sounds like the right approach to me:

    while select vendTrans
    	join tri_NettingCorrelationAP
    		where tri_NettingCorrelationAP.TRI_PurchAccount == vendTrans.AccountNum
    		   && ( vendTrans.Voucher like 'AF*'
    		     || vendTrans.Voucher like 'FF*')

    Nevertheless it seems that the root cause is in the data model.

  • mimi51340 Profile Picture
    on at
    RE: Add a filter in where clause

    Thanks what do you think by Nevertheless it seems that the root cause is in the data model ?

  • Martin Dráb Profile Picture
    on at
    RE: Add a filter in where clause

    If you have difficulties to query your data, it usually means that your data model isn't designed correctly. It doesn't support well what you need from it.

    In this case, you seem to be using a part of the voucher ID to categorize transactions, but this categorization should be ideally stored in a separate field. Filtering by such a field would be trivial.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans