I have a Global field to calculate a Total with a SQL string. I'am not very familiar with SQL and i want to add an additional filter.

I would like to add the following additional filter to the SQL String: Count only field "Totaal" from table "Facturen" where field "Type" is "Origineel".

Let (

[

month = Bedrijfsdashboard::Huidige maand ;

year = Bedrijfsdashboard::Huidig jaar ;

status = Statusfilter ;

decimal = Left ( Evalueren ( 1/2 ) ; 1 ) ;

SQL = ExecuteSQL (

"

SELECT SUM ( a.\"Totaal\" )

FROM \"Facturen\" a " &

If (

IsEmpty ( status ) ;

"WHERE a.\"Maand\" = ? AND a.\"Jaar\" = ? AND a.\"Statusvolgorde\" IN ( 0 ,1, 2 ) " ;

"WHERE a.\"Maand\" = ? AND a.\"Jaar\" = ? AND a.\"Statusvolgorde\" = ? "

)

; "" ; "" ;

month ; year ; status

)

] ;

If ( SQL ; Substitute ( SQL; "." ; decimal ) ; 0 )

)

If I understand correctly, you could probably adjust your calculation as follows:

Let (

[

month = Bedrijfsdashboard::Huidige maand ;

year = Bedrijfsdashboard::Huidig jaar ;

status = Statusfilter ;

decimal = Left ( Evalueren ( 1/2 ) ; 1 ) ;

SQL = ExecuteSQL (

"

SELECT SUM ( a.\"Totaal\" )

FROM \"Facturen\" a

WHERE a.\"Maand\" = ? AND a.\"Jaar\" = ? AND a.\"Type\" = ?" &

If (

IsEmpty ( status ) ;

" AND a.\"Statusvolgorde\" IN ( 0 ,1, 2 ) " ;

" AND a.\"Statusvolgorde\" = ? "

)

; "" ; "" ;

month ; year ; "Origineel" ; status

)

] ;

If ( SQL ; Substitute ( SQL; "." ; decimal ) ; 0 )

)