Skip to main content
Announcements
The way to achieve your own success is the willingness to help somebody else. Go for it!
cancel
Showing results for 
Search instead for 
Did you mean: 
aftabn10
Contributor III
Contributor III

How to Show Selection Value in Label

Hi, I am looking to find out how I can display a value in a Label within a measure Measure based on a selection from a SimpleFieldSelect Extension.

I currently have the following 4 options on my page:

A | B | C | D

at present I have the following as part of my label:

=FieldValue('product_name', '1')

which I know will always show the first value no matter what I select. What I would like to do is to make this label dynamic so that this displays a single value of whatever is selected i.e. A, B, C or D and if more than 1 value is selected than I would like this value to change to ALL.

I am not sure if this is possible to do within the label field or whether I need to create a variable and then call it, but would love some advice as to what the best practice is to achieve this.

1 Solution

Accepted Solutions
tresesco
MVP
MVP

If(getSelectedCount(product_name)=1, product_name, 'ALL')

View solution in original post

5 Replies
tresesco
MVP
MVP

If(getSelectedCount(product_name)=1, product_name, 'ALL')

aftabn10
Contributor III
Contributor III
Author

Wow that was quick lol. Will give that a go. Thank you.
aftabn10
Contributor III
Contributor III
Author

Brilliant, thank you so much, that worked!

primopapp00
Contributor
Contributor

Hello @tresesco .

What would this command  turn into if we want to show 2 selected values?

For example I've put a filter pane for Year select in the dashboard and a KPI showing Values based on the Years selected. With the command given above, if I select 2023, the label shows "2023". But if I select 2022 and 2023 in the filter pane, I would like to see "2022-2023" in the label section. Is this possible with a nested "if" in the given command?

I've tried this : 

 

If(getSelectedCount([Έτος])=1,'Stock Value '& Έτος,
If(getSelectedCount([Έτος])=2,'Stock Value '& Έτος,
'ALL'))

but it's obviously wrong.

Thank you in advance.

primopapp00
Contributor
Contributor

Finally, I found something that seems to work :

=If(getSelectedCount([Έτος])=1,'Stock Value ' & GetFieldSelections ([Έτος],','),
If(getSelectedCount([Έτος])=2,'Stock Value ' & GetFieldSelections ([Έτος],','),
If(getSelectedCount([Έτος])=3,'Stock Value ' & GetFieldSelections ([Έτος],','),
If(getSelectedCount([Έτος])=4,'Stock Value ' & GetFieldSelections ([Έτος],','),
If(getSelectedCount([Έτος])=5,'Stock Value ' & GetFieldSelections ([Έτος],','),
If(getSelectedCount([Έτος])=6,'Stock Value ' & GetFieldSelections ([Έτος],','),
'ALL'))))))

 

Where Έτος means year, and i did 6 ifs because max value of years are 7 (2017,2018,2019,2020,2021,2022,2023)

 

If you can suggest a shorter query, it would be much appreciated !