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 :
Small and medium business | Business Central, N...
Suggested answer

AL language. If condtion on columns

(0) ShareShare
ReportReport
Posted on by 271
Dears.
 
I am creting a query type=API
 
In Sales Line table i have 3 lines . 
1-Item1 /UOM=PCS =Total 100
2-Item2 /UOM=PCS =Total 50
3-Item3/UOM=Service Total 5.
Grand Total =155.
 
But on Sales Hader Level i am getting all fields but i want to add two columns Total 
If Item UOM =pcs  then TotalItemsSold 150
If Item UOM =Service then Total ServicesValue =5
 
How i can use If condtion or Filter to Sum up Sales Line based on condtion on field UOM.
 
Thanks in advance.
Aqeel.
 
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    93,872 Super User 2025 Season 2 on at
    AL language. If condtion on columns
    Hi, as far as I know, it can't be done using Query.
    When using Page, you can specify conditions in the field's Visible Property and you can also add calculation logic, but this cannot be used in Query.
     
    Or, you create two Query APIs respectively, UOM =pcs calls A, and UOM =Service calls B. But this is a bit troublesome.
    Or you can simply try $filter.
     
     
    Hope this can give you some hints.
    Thanks.
    ZHU

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 > Small and medium business | Business Central, NAV, RMS

#1
Sumit Singh Profile Picture

Sumit Singh 2,179

#2
OussamaSabbouh Profile Picture

OussamaSabbouh 1,999

#3
YUN ZHU Profile Picture

YUN ZHU 1,892 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans