Use an Advanced Query when the columns you need come from different systems. In this example, one Connection Profile supplies account balances and another supplies payment history. The finished View shows each account’s balance and latest posted payment date in a single grid, including accounts that have never had a posted payment.
Prepare the View
- In VDM 2026.12.2.0 or later, identify the two saved Connection Profiles you want to query. Check that the same account ID identifies the same account in both systems.
- In Settings > MDS > SQL Database, select the SQL Server database VDM will use to combine the results. VDM loads each source result into a temporary table there for the duration of the run.
- Create a View and open Advanced Query. The example uses the default query separator
;;and name markerMQN_As. If your View uses custom values, substitute them in the example.
Enter the three query segments
Paste the full example into the Advanced Query editor. Replace AccountsProfile and PaymentsProfile with your saved profile names. The table names, columns and status value are examples. Use your systems’ names and SQL syntax in the first two segments, and match the payment filter to the rule your existing report uses for posted payments.
{ConnectionProfile:AccountsProfile}
SELECT AccountID, Balance
FROM Accounts
MQN_As AccountBalances
;;
{ConnectionProfile:PaymentsProfile}
SELECT AccountID, MAX(PostingDate) AS LastPaymentDate
FROM Payments
WHERE PaymentStatus = 'Posted'
GROUP BY AccountID
MQN_As LastPayment
;;
{MDSQuery}
SELECT a.AccountID, a.Balance, p.LastPaymentDate
FROM #AccountBalances AS a
LEFT JOIN #LastPayment AS p ON p.AccountID = a.AccountID
ORDER BY a.AccountIDThe first segment returns one balance row per account. The second groups payments by account so that several payments produce one latest date. The third segment runs on the MDS SQL Database and uses SQL Server syntax. Each name after MQN_As becomes a table you can reference by adding #. Use exactly one {MDSQuery} segment and put a Connection Profile marker only on the source segments.
Run and check the result
- Select Run View. The grid should contain AccountID, Balance and LastPaymentDate.
- Check an account with several posted payments. It should appear once, with the balance from the accounts system and the most recent qualifying date from the payments system. Check an account with no posted payments as well. The left join keeps its balance in the grid and leaves its payment date blank.
- Save the View. If you plan to schedule it, also set the MDS SQL Database in the Scheduler Service.
If the results look wrong
- An account appears twice. Check that the accounts query returns one row per account ID and the payments query groups by that same ID. An extra grouping field, such as payment method, can produce several rows for one account.
- A known payment date is blank. Check that the payment passes your posted-payment filter and that its account ID matches the value in the accounts source. For text IDs, compare leading zeros in the two systems.
-
VDM reports a missing profile or table. Check the saved name in each
{ConnectionProfile:...}marker. In the final query, use the source result name, such as#AccountBalances, even when the original table has a different name.
For more about separating queries in a View, see How to Use Multi Query in Advanced Query.
Comments
0 comments
Please sign in to leave a comment.