This is a migrated thread and some comments may be shown as answers.

Count number of selected values in Multi Value Parameter

6 Answers 3572 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kanchana
Top achievements
Rank 1
Kanchana asked on 08 Jun 2017, 02:25 PM

Hi,

Is there a way to count the number of selected values in a multi-valued report parameter? I know the result of a multi-valued parameter is an object array (Object[]) but I would like to know the number of items in the array. 

Also, is there a way to know if  <select all> option is checked or unchecked, in other words if all values are selected or not?

 

Thank you.

 

 

6 Answers, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 09 Jun 2017, 08:58 AM
Hi Kanchana,

To count a number of values in multivalue parameter you can use the following expression in report:
= Parameters.Parameter1.Value.Length

To check if all values are selected compare the above value with parameter's AvailableValues.Count value:
// returns true or false
= Parameters.Parameter1.Value.Length = Parameters.Parameter1.AvailableValues.Count

Hope this helps.


Regards,
Katia
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Kanchana
Top achievements
Rank 1
answered on 09 Jun 2017, 09:03 AM
Worked like a wonder... Thank you.
0
Phil
Top achievements
Rank 1
answered on 01 Mar 2018, 12:09 AM

Similar to this:

Is there a property I can use to see which value(s) are selected?

If I have selected 1 and 3 in the multi value parameter list...

I would like to say If parameter.value.contains 1 then do this... if contains 2 then do this...

0
Anthony
Top achievements
Rank 1
answered on 04 Jul 2019, 03:58 PM
[quote]Phil said:

Similar to this:

Is there a property I can use to see which value(s) are selected?

If I have selected 1 and 3 in the multi value parameter list...

I would like to say If parameter.value.contains 1 then do this... if contains 2 then do this...

[/quote]

IIf (Parameters.Parameter1.Value.Lenght = 1, 'do this 1', IIF (Parameters.Parameter1.Value.Lenght = 2, 'do this 2', IIf (Parameters.Parameter1.Value.Lenght = 3, 'do this 3', 'then selection is either bigger than 3 or = 0')))

Hope you find it useful!

0
Aaron
Top achievements
Rank 1
answered on 11 Dec 2019, 09:33 AM
[quote]Katia said:Hi Kanchana,

To count a number of values in multivalue parameter you can use the following expression in report:
= Parameters.Parameter1.Value.Length

To check if all values are selected compare the above value with parameter's AvailableValues.Count value:
// returns true or false
= Parameters.Parameter1.Value.Length = Parameters.Parameter1.AvailableValues.Count

Hope this helps.


Regards,
Katia
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items

[/quote]

 

When I dont select anything and just choose Null for a multivalue parameter then the Length field doesnt return 0 and I am unable to Compare to Blank or Null. How does one determine if a MultiValue parameter is Null or Empty.

Thanks,
Aaron

0
Todor
Telerik team
answered on 16 Dec 2019, 09:19 AM

Hi Aaron,

Indeed, when the MultiValue parameter is Null, it does not return an empty collection, hence no Length property. You may use Expressions like:

= IsNull(Parameters.Parameter1.Value, 'Null')

and

= Parameters.Parameter1.Value ?? 'Null'

to check for Null value of the Report Parameter. In the examples when the MultiValue parameter is Null the Expression will return the string 'Null', otherwise - the array with parameter values.

If you would like to check the number of values in a MultiValue parameter and return '0' in the parameter is Null you may use:

= (Parameters.Parameter1.Value ?? Array()).Length

Regards,
Todor
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Kanchana
Top achievements
Rank 1
Answers by
Katia
Telerik team
Kanchana
Top achievements
Rank 1
Phil
Top achievements
Rank 1
Anthony
Top achievements
Rank 1
Aaron
Top achievements
Rank 1
Todor
Telerik team
Share this question
or