(Newbie] Count elements which are not null

Stimulsoft Reports.NET discussion
Post Reply
iluvthisgame
Posts: 4
Joined: Thu Apr 29, 2021 2:18 pm

(Newbie] Count elements which are not null

Post 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
Lech Kulikowski
Posts: 6163
Joined: Tue Mar 20, 2018 5:34 am

Re: (Newbie] Count elements which are not null

Post 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.
iluvthisgame
Posts: 4
Joined: Thu Apr 29, 2021 2:18 pm

Re: (Newbie] Count elements which are not null

Post 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.
Lech Kulikowski
Posts: 6163
Joined: Tue Mar 20, 2018 5:34 am

Re: (Newbie] Count elements which are not null

Post by Lech Kulikowski »

Hello,

Please let us know if you need any additional help.
iluvthisgame
Posts: 4
Joined: Thu Apr 29, 2021 2:18 pm

Re: (Newbie] Count elements which are not null

Post by iluvthisgame »

Hello & sorry, It's OK for me ! Thx
Andrew
Posts: 4104
Joined: Fri Jun 09, 2006 3:58 am

Re: (Newbie] Count elements which are not null

Post by Andrew »

Hello,

You are welcome!
Post Reply