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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

putting virtual field/computed column in ranges

(0) ShareShare
ReportReport
Posted on by 1,552

Hi,

I want to put a range on the entity that says the following:

(((EnumField == 0) && (VirtualFieldEnum == 1)) || (EnumField == 1))

but it seems i can't put virtualFieldEnum in the datasource of the entity as a range.

How can i do this inside the entity? i don't want to put a range on data project, is this possible? i also saw comments in other posts about advanced filtering, would this achieve my result without putting a range on data project? if yes can someone help me how to do it?

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

    Hi junior AX,

    Could you please share the logic for the virtual field that you want to use in the data entity range?

  • André Arnaud de Calavon Profile Picture
    301,321 Super User 2025 Season 2 on at

    Hi Junior AX,

    There is a difference between computed columns and virtual fields. docs.microsoft.com/.../data-entity-computed-columns-virtual-fields

    You can't filter on virtual fields. It is possible to filter on computed columns; depending on the situation. Can you elaborate exactly what you try to achieve and where you had put the range (Query level or in x++)?

  • Blue Wang Profile Picture
    on at

    Hi Junior AX,

    As Andre mentioned , Virtual field cannot be filtered. virtual fields are computed row by row in X++.

    When you use data management , create a export job then add your entity , After that you can find filter column in that. you can apply advanced filter in it.

    2642.PNG

    0815.PNG

  • junior AX Profile Picture
    1,552 on at

    Hi Gunjan, Andre and Blue,

    I'm trying to do the range for an entity (where table1 and the entity dataSource are the same and Id is entityKey)

        public void postLoad()
        {
            super();
            
            Table1 table1;
            select table1 where table1.ParmId == this.ParmId
                 && child.Id  !=  this.Id;
                 
            this.virtualFieldEnum = child.EnumField;
        }

    1. could this be done with computed column? as i don't want to put the range on data project

    2. Also Blue, i went to the filter screen in data project but i couldn't find my virtual field? how can i make it appear there?

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi JuniorAX,

    As it was mentioned already, virtual fields can't be used in filters as there are calculated after data is requested from DB. It can be replaced with a computed field if you will use a sub-query. But if you don't want to put a range on the data project, how are you planning to filter by that field?

  • junior AX Profile Picture
    1,552 on at

    Hi Sergie,

    I'm not sure if i can replace my virtual logic to a computed column.

    1. So you are saying computed columns can be filtered inside the data entity itself but virtual fields can only be filtered in data projects?

    2. Why i can't see my virtual field in data project filter?

  • Martin Dráb Profile Picture
    238,032 Most Valuable Professional on at

    You can't use virtual fields in database queries against entities, because virtual fields don't exist in database at all. Computed columns do.

  • junior AX Profile Picture
    1,552 on at

    Hi Martin,

    I added a virtual field and a computed column to the entity but i couldn't see both field in data projects

    1. So you are saying i can't filter on virtual fields at all even in the data project?

    2. based on your sentence "You can't use virtual fields in database queries against entities, because virtual fields don't exist in database at all". I had a scenario where put relation on the staging table based on the virtual field and it worked d even though the field doesn't exist in the database. Is that normal?

    3. So i can filter computed column both in entity itself and in data project. why i can't see the computed column in data project? and how can i put a range on the entity using the computed column

  • Martin Dráb Profile Picture
    238,032 Most Valuable Professional on at

    1) I believe so.

    2) I was talking about data entities, not staging tables. When entity data is exported (possibly with filters applied), postLoad() is executed and - if it's using data management - the data is written to a staging table. You look into the stanging table and filter the data, but it's a different thing than filtering the entity.

    3) Please elaborate your problem.

  • junior AX Profile Picture
    1,552 on at

    Hi Martin,

    So i created a computed column and i want to apply a range on it where the value =1 for example.

    1. Can i put the range on the entity? Can i put it under the main dataSource?

    2. I want to try and put a range for the computed column on data project, i clicked the filter button and i couldn't find my computed column there, how can i make it appear and filter on it?

    3. and continuing point 2 in the other reply, i put the relation on the entity itself as well not just the staging using virtual field.

    ChildEntity.Field = ParentEntity.VirtualField

    ChildEntityStagingTable.Field = ParentEntityStagingTable.VirtualField

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

News and Announcements

Season of Giving Solutions is Here!

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
Abhilash Warrier Profile Picture

Abhilash Warrier 678 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 281 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans