Ok, if I modify the Description to append USER~{:CURRENTUSER}
, like this:
[:CommandValue] {SETTING:ATx AccountType} Tx {SETTING:ATx Currency} ({SETTING:ATx Desc}) USER~{:CURRENTUSER}
Then I can run this SQL to filter the User
DECLARE @user varchar(50) = 'Q'
SELECT
[txName]
,sum([Exchange]) as [Amount]
,max([AccountSRC]) as [AccountSRC]
,max([AccountTGT]) as [AccountTGT]
,[txDate]
FROM (
SELECT
tv.[Name] as [txName]
--,[Debit]
--,[Credit]
,0 as [Exchange]
,null as [AccountSRC]
,a.[Name] as [AccountTGT]
,[Date] as [txDate]
FROM [AccountTransactionValues] tv
JOIN [Accounts] a on a.[Id]=tv.[AccountId]
JOIN [AccountTypes] atyp on atyp.[Id]=tv.[AccountTypeId]
JOIN [AccountTransactionTypes] attyp on attyp.[Id]=tv.[AccountTransactionTypeId]
JOIN [AccountTransactions] tx on tx.[Id]=tv.[AccountTransactionId]
where 1=1
AND tv.[Debit]!=0
--AND tv.[Credit]!=0
UNION
SELECT
tv.[Name] as [txName]
--,[Debit]
--,[Credit]
,[Exchange]*-1 as [Exchange]
,a.[Name] as [AccountSRC]
,null as [AccountTGT]
,[Date] as [txDate]
FROM [AccountTransactionValues] tv
JOIN [Accounts] a on a.[Id]=tv.[AccountId]
JOIN [AccountTypes] atyp on atyp.[Id]=tv.[AccountTypeId]
JOIN [AccountTransactionTypes] attyp on attyp.[Id]=tv.[AccountTransactionTypeId]
JOIN [AccountTransactions] tx on tx.[Id]=tv.[AccountTransactionId]
where 1=1
--AND tv.[Debit]!=0
AND tv.[Credit]!=0
) u
WHERE [txName] LIKE '%USER~'+@user+'%'
GROUP BY
[txName]
,[txDate]
Which produces this:
So I can change the Report to use {REPORT SQL DETAILS:X}
…
[Account Transactions:1,1,1,1, 1]
@Q,
>>Date|Type|SRC|TGT|Amount
{REPORT SQL DETAILS:
SELECT
txName
,sum(Exchange) as Amount
,max(AccountSRC) as AccountSRC
,max(AccountTGT) as AccountTGT
,txDate
FROM (
SELECT
tv.[Name] as [txName]
--,[Debit]
--,[Credit]
,0 as [Exchange]
,null as [AccountSRC]
,a.[Name] as [AccountTGT]
,[Date] as [txDate]
FROM [AccountTransactionValues] tv
JOIN [Accounts] a on a.[Id]=tv.[AccountId]
JOIN [AccountTypes] atyp on atyp.[Id]=tv.[AccountTypeId]
JOIN [AccountTransactionTypes] attyp on attyp.[Id]=tv.[AccountTransactionTypeId]
JOIN [AccountTransactions] tx on tx.[Id]=tv.[AccountTransactionId]
where 1=1
AND tv.[Debit]!=0
--AND tv.[Credit]!=0
UNION
SELECT
tv.[Name] as [txName]
--,[Debit]
--,[Credit]
,[Exchange]*-1 as [Exchange]
,a.[Name] as [AccountSRC]
,null as [AccountTGT]
,[Date] as [txDate]
FROM [AccountTransactionValues] tv
JOIN [Accounts] a on a.[Id]=tv.[AccountId]
JOIN [AccountTypes] atyp on atyp.[Id]=tv.[AccountTypeId]
JOIN [AccountTransactionTypes] attyp on attyp.[Id]=tv.[AccountTransactionTypeId]
JOIN [AccountTransactions] tx on tx.[Id]=tv.[AccountTransactionId]
where 1=1
AND tv.[Credit]!=0
) u
WHERE [txName] LIKE '%USER~$1'+'%'
GROUP BY
[txName]
,[txDate]
:F.txDate,F.txName,F.AccountSRC,F.AccountTGT,F.Amount
}
So that ^ uses an @LIST
for Users:
@Q,
And it replaces the $1
variable here:
WHERE [txName] LIKE '%USER~$1'+'%'
… to produce this: