Page 1 of 1

(Newbie] Count elements which are not null

Posted: Fri Sep 10, 2021 2:59 pm
by iluvthisgame
Hello & sorry for my english & my lvl :D

I use Stimulsoft Reports.net to make print reports in my management software (it is provided with this editor)

I need to count 8 variables (from custom fields in my management software) if and only if they are not zero

The variables are :

SaleDocument.ContactFields_Name
SaleDocument.ContactFields_Name1
SaleDocument.ContactFields_Name3
SaleDocument.ContactFields_Name5
SaleDocument.ContactFields_Name7
SaleDocument.ContactFields_Name9
SaleDocument.ContactFields_Name11
SaleDocument.ContactFields_Name13

I tried to do something like :

Code: Select all

{Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name),"0","1")) + 
Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name1),"0","1")) + 
Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name3),"0","1")) + 
Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name5),"0","1")) + 
Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name7),"0","1")) + 
Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name9),"0","1")) + 
Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name11),"0","1")) + 
Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name13),"0","1"))}
But it gave me this:

11100000

Don't know how to do that

iLtG

Re: (Newbie] Count elements which are not null

Posted: Mon Sep 13, 2021 1:48 pm
by Lech Kulikowski
Hello,

Yes, that correct result. In your expression are used string values.

Please check:

Code: Select all

{Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name),0,1)) + 
(int)IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name1),0,1) + 
(int)IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name3),0,1) + 
(int)IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name5),0,1) + 
(int)IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name7),0,1) + 
(int)IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name9),0,1) + 
(int)IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name11),0,1) + 
(int)IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name13),0,1))}
Thank you.

Re: (Newbie] Count elements which are not null

Posted: Tue Sep 14, 2021 7:28 am
by iluvthisgame
Hello,

Thks but unfortunately i've got this error :
Erreur de compilation
Une erreur de compilation a été trouvée dans la propriété 'Text' du composant 'Text15' :
Terme d'expression non valide 'int'
Compilation error
A compilation error was found in the 'Text' property of the 'Text15' component:
Invalid expression term 'int'
So i've done this and it works :

Code: Select all

Nombre de stagiaire(s) : {Length(Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name),"","1")) + 
Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name1),"","1")) + 
Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name3),"","1")) + 
Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name5),"","1")) + 
Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name7),"","1")) + 
Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name9),"","1")) + 
Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name11),"","1")) + 
Format("{0:N0}", IIF(String.IsNullOrEmpty(SaleDocument.ContactFields_Name13),"","1")))}
Apparently the editor is not complete and has been restricted by the management software editor or the syntax is not good.

Re: (Newbie] Count elements which are not null

Posted: Tue Sep 14, 2021 9:02 pm
by Lech Kulikowski
Hello,

Please let us know if you need any additional help.

Re: (Newbie] Count elements which are not null

Posted: Fri Sep 17, 2021 1:29 pm
by iluvthisgame
Hello & sorry, It's OK for me ! Thx

Re: (Newbie] Count elements which are not null

Posted: Sat Sep 18, 2021 4:38 pm
by Andrew
Hello,

You are welcome!