Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

AL language. If condtion on columns

Posted on by 62
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.
 
Categories:
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,565 Super User 2024 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans