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 :
Microsoft Dynamics NAV (Archived)

create sql query based flow filter

(0) ShareShare
ReportReport
Posted on by

I'm trying to create the sql query code based on a flow filter calc formula

So I have the table "Vendor Ledger Entry" with a important field called "Remaining Amount". This is a flowfield, calculated based on formulas with other tables(in this case Detailed Vendor Ledger Entry

Remaining Amount: `"Sum("Detailed Vendor Ledg. Entry".Amount WHERE (Vendor Ledger Entry No.=FIELD(Entry No.),Posting Date=FIELD(Date Filter),Excluded from calculation=CONST(No)))"`


So I "convert" the "Remaining Amount" to this sql query

Select Sum([E18375$Detailed Vendor Ledg_ Entry].[Amount]) as 'Valor pendente'
FROM [E18375$Detailed Vendor Ledg_ Entry]
INNER JOIN [E18375$Vendor Ledger Entry] ON [E18375$Detailed Vendor Ledg_ Entry].[Entry No_] = [E18375$Vendor Ledger Entry].[Entry No_]
WHERE [E18375$Detailed Vendor Ledg_ Entry].[Excluded from calculation] = 0 and [E18375$Vendor Ledger Entry].[Document No_]='1707NC006' and [E18375$Detailed Vendor Ledg_ Entry].[Amount]>0


The problem is I get the value "Valor pendente" equals to "NULL" instead of "10" like the image below.


I follow this example i found online to create my sql query..


Sum("Detailed Cust. Ledg. Entry"."Amount (LCY)" WHERE (Cust. Ledger Entry No.=FIELD(Entry No.),Entry Type=FILTER(Initial Entry),Posting Date=FIELD(Date Filter)))

Select Sum([Amount (LCY)] FROM [Detailed Cust. Ledg. Entry]
INNER JOIN
[Cust. Ledg. Entry]
ON
[Detailed Cust. Ledg. Entry].[Entry No.] = [Cust. Ledg. Entry].[Entry No.]
WHERE
[Detailed Cust. Ledg. Entry].[Entry Type] = "Initial Entry"


ana_5F00_valor-pendente.png

I need the "Empresa", Posting Date, document No and Vendor No (from detailed vendor ledger entry) and Remaining Amount (the flowfield I want to "convert")

My full query is here below:

select 'E18375' as Empresa, [E18375$Detailed Vendor Ledg_ Entry].[Posting Date],
[E18375$Detailed Vendor Ledg_ Entry].[Document No_],
[E18375$Detailed Vendor Ledg_ Entry].[Vendor No_],
[E18375$Detailed Vendor Ledg_ Entry].Amount, (Select Sum([Amount (LCY)])
FROM [E18375$Detailed Vendor Ledg_ Entry]
INNER JOIN [E18375$Vendor Ledger Entry] ON [E18375$Detailed Vendor Ledg_ Entry].[Entry No_] = [E18375$Vendor Ledger Entry].[Entry No_]
WHERE [E18375$Detailed Vendor Ledg_ Entry].[Excluded from calculation]=0
AND [E18375$Detailed Vendor Ledg_ Entry].[Amount]>0) as 'Valor pendente'
from [E18375$Vendor Ledger Entry] inner join [E18375$Detailed Vendor Ledg_ Entry] on [E18375$Detailed Vendor Ledg_ Entry].[Vendor Ledger Entry No_]=[E18375$Vendor Ledger Entry] .[Entry No_]
where [E18375$Vendor Ledger Entry].[Open]=1 and [E18375$Detailed Vendor Ledg_ Entry].[Document No_]='1707NC006'
group by [E18375$Detailed Vendor Ledg_ Entry].[Posting Date], [E18375$Detailed Vendor Ledg_ Entry].[Document No_],
[E18375$Detailed Vendor Ledg_ Entry].[Vendor No_], [E18375$Detailed Vendor Ledg_ Entry].[Vendor Ledger Entry No_],
[E18375$Detailed Vendor Ledg_ Entry].[Amount]
having sum([E18375$Detailed Vendor Ledg_ Entry].[Amount])>0



*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    I can’t test the query now but I’m not sure you’re doing the righ join. The Remaining Amount SQL query is wrong, You have to join [Detailed Vendor Ledger Entry].[Vendor Ledger Entry No] = [Vendor Ledger Entry].[Entry No]

    Split the query in pieces and test it with SSMS.

  • Community Member Profile Picture
    on at

    Right, but with that join I get the value "1838" instead of "10", I even use a filter to the "Posting Date" field with year(Posting Date) > 2071 and I get the same value "1838"

    0825.ana_5F00_valor-pendente.png

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 > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans