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

Notifications

Announcements

No record found.

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 50

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

I have the same question (0)
  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    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
    237,884 Most Valuable Professional on at

    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
    50 on at

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

  • Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at

    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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 565 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans