Visual is good … (except I want ‘-’ instead of blank)
Printed is bad - an I want ‘-’ instead of blank.
My template:
@ Karina,Celia,Ingrid,Grecia,
[Cajas:4, 1]
>>$1
Venta|{REPORT PAYMENT TOTAL:(PT=Cash) AND (PU=$1) and (TY=Ticket)}
{REPORT SQL DETAILS:
SELECT
‘Cash In/Cash Out’ as CashIN
,IIF(sum([Debit]+[Credit]) > 0,‘-’,sum([Debit]+[Credit]*-1)) as [txTotal]
FROM [AccountTransactionValues]
WHERE [Name] LIKE ‘%$1’+‘%’ AND [AccountId]=5
AND SUBSTRING(REPLACE(CONVERT(varchar(50),[Date],126),‘T’,’ ‘),1,16) >= SUBSTRING(REPLACE(CONVERT(varchar(50),’{Start}‘,126),‘T’,’ ‘),1,16)
AND SUBSTRING(REPLACE(CONVERT(varchar(50),[Date],126),‘T’,’ ‘),1,16) <= SUBSTRING(REPLACE(CONVERT(varchar(50),’{End}‘,126),‘T’,’ ‘),1,16)
:F.CashIN,F.txTotal
}
>Total|[=F(TN(’{REPORT PAYMENT TOTAL:(PT=Cash) AND (PU=$1) and (TY=Ticket)}‘)+TN(’{REPORT SQL DETAILS: SELECT sum([Debit]+[Credit]*-1) as [txTotal] FROM [AccountTransactionValues] WHERE [Name] LIKE ‘%$1’+‘%’ AND [AccountId]=5 AND SUBSTRING(REPLACE(CONVERT(varchar(50),[Date],126),‘T’,’ ‘),1,16) >= SUBSTRING(REPLACE(CONVERT(varchar(50),’{Start}‘,126),‘T’,’ ‘),1,16) AND SUBSTRING(REPLACE(CONVERT(varchar(50),[Date],126),‘T’,’ ‘),1,16) <= SUBSTRING(REPLACE(CONVERT(varchar(50),’{End}‘,126),‘T’,’ ‘),1,16) :F.txTotal }’))]
Ok I understand, If there is no transaction, Debit does not exist, SQL reports 0 row, so we will not enter in the IF test clause, so no “-”.
I have to replace “empty” outside of the {REPORT}, so:
Is now:
@ Karina,Celia,Ingrid,Grecia,
[Cajas:4, 1]
>>$1|
Venta|{REPORT PAYMENT TOTAL:(PT=Cash) AND (PU=$1) and (TY=Ticket)} Cash In/Cash Out|[=F(TN(‘{REPORT SQL DETAILS:SELECT sum([Debit]+[Credit]*-1) as [txTotal] FROM [AccountTransactionValues] WHERE [Name] LIKE ‘%$1’+’%’ AND [AccountId]=5 AND SUBSTRING(REPLACE(CONVERT(varchar(50),[Date],126),‘T’,’ ‘),1,16) >= SUBSTRING(REPLACE(CONVERT(varchar(50),’{Start}‘,126),‘T’,’ ‘),1,16) AND SUBSTRING(REPLACE(CONVERT(varchar(50),[Date],126),‘T’,’ ‘),1,16) <= SUBSTRING(REPLACE(CONVERT(varchar(50),’{End}‘,126),‘T’,’ ‘),1,16):F.txTotal}’))]
>Total|[=F(TN(‘{REPORT PAYMENT TOTAL:(PT=Cash) AND (PU=$1) and (TY=Ticket)}’)+TN(‘{REPORT SQL DETAILS: SELECT sum([Debit]+[Credit]*-1) as [txTotal] FROM [AccountTransactionValues] WHERE [Name] LIKE ‘%$1’+’%’ AND [AccountId]=5 AND SUBSTRING(REPLACE(CONVERT(varchar(50),[Date],126),‘T’,’ ‘),1,16) >= SUBSTRING(REPLACE(CONVERT(varchar(50),’{Start}‘,126),‘T’,’ ‘),1,16) AND SUBSTRING(REPLACE(CONVERT(varchar(50),[Date],126),‘T’,’ ‘),1,16) <= SUBSTRING(REPLACE(CONVERT(varchar(50),’{End}‘,126),‘T’,’ ‘),1,16) :F.txTotal }’))]
I don’t have my ‘-’, but at least I have 0.00 instead of empty, printed report is easier to read.
It seems that you’ve got your problem under control, but just for future reference, to see if a value is null in SQL you can use the “[rowName] IS NULL”.