Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
hammermill21
Creator III
Creator III

GetFieldSelections question

Hello!

I am creating a variable for when a building is selected. My expression for my building filter is: 

=Trim(Upper(Replace(building, '_', ' '))) & Trim(Upper(Replace(enter_building, '_', ' '))), now I"m trying to create a variable for GetFieldSelctions using my building expression but it doesn't work. 

Any ideas?

 

Thank you!

1 Solution

Accepted Solutions
sunny_talwar

I guess you have building and enter_building both in your selection box... why do you need both? can you not create a new field in the script using your logic

Trim(Upper(Replace(building, '_', ' '))) & Trim(Upper(Replace(enter_building, '_', ' '))) as NewBuildingName

and then use this in your filter object with this expression for KPI

If(GetSelectedCount(NewBuildingName) = 1,
Concat(DISTINCT NewBuildingName),
'All buildings are reflected in the data below unless a building filter is selected')

or this

If(GetSelectedCount(NewBuildingName) > 0,
Concat(DISTINCT NewBuildingName),
'All buildings are reflected in the data below unless a building filter is selected')

View solution in original post

22 Replies
sunny_talwar

What exactly do you mean by this


@hammermill21 wrote:

now I'm trying to create a variable for GetFieldSelctions using my building expression


you are using an expression within  GetFieldSelections() function? I believe the function only takes field name and not an expression.

hammermill21
Creator III
Creator III
Author

Hey Sunny,

 

Then that's my issue, if the function only takes a field name then it won't work.  I'm trying to figure out how I can display the building name that is selected with the current function I have.  

sunny_talwar

Can you show by a mean of an image or example what exactly are you looking for? May be you can use something like this

=Trim(Upper(Replace(GetFieldSelections(building), '_', ' '))) &
Trim(Upper(Replace(GetFieldSelections(enter_building), '_', ' ')))

or something using Concat.... like this

=Concat(Trim(Upper(Replace(building, '_', ' '))) &
 Trim(Upper(Replace(enter_building, '_', ' '))))
hammermill21
Creator III
Creator III
Author

So what I want is when I select a building on the left-hand side, it shows up in my text box:

Capture.PNG

I tried  creating a variable with the GetFieldSelections() but I cna't with an expression. I tried using the one below but that doesn't work.

 

=Trim(Upper(Replace(GetFieldSelections(building), '_', ' '))) &
Trim(Upper(Replace(GetFieldSelections(enter_building), '_', ' ')))

 And when I use the Concat this happens:

Capture2.PNG

sunny_talwar

Try this

If(GetSelectedCount(building) = 1,
Concat(DISTINCT
Trim(Upper(Replace(building, '_', ' '))) & Trim(Upper(Replace(enter_building, '_', ' ')))
) )
hammermill21
Creator III
Creator III
Author

Nope that doesn't return anything, not even an error. 

sunny_talwar

Have you selected a single building? Without selection it won't return anything. You need to select only 1 building.... for multiple.. try this

If(GetSelectedCount(building) > 0,
  Concat(DISTINCT
    Trim(Upper(Replace(building, '_', ' '))) &
    Trim(Upper(Replace(enter_building, '_', ' ')))
  )
)

If you want to see without selection, try this

Concat(DISTINCT
    Trim(Upper(Replace(building, '_', ' '))) &
    Trim(Upper(Replace(enter_building, '_', ' ')))
)
hammermill21
Creator III
Creator III
Author

Thank you Sunny!

Concat(DISTINCT
    Trim(Upper(Replace(building, '_', ' '))) &
    Trim(Upper(Replace(enter_building, '_', ' ')))
)

This one worked 🙂

One last question, if I wanted to add a Calculation condition  I can't just write 

Concat(DISTINCT
Trim(Upper(Replace(building, '_', ' '))) &
Trim(Upper(Replace(enter_building, '_', ' ')))
) <= 1

Becuase that doesn't work, could I even add a calculation conditionto this?

sunny_talwar

May be this

If(Len(Trim(
Concat(DISTINCT Trim(Upper(Replace(building, '_', ' '))) & Trim(Upper(Replace(enter_building, '_', ' '))) )
) > 0