Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
padmanabhv
Contributor III
Contributor III

Sort Variable values and print in text box

Hi,
Lets say I have a bunch of variables:
v1, v2, v3 - which are text GetFieldSelections based on selected filters,

and v1c,v2c,v3c - which are count of distinct values for corresponding variables.

Totally 6 variables, which get their values populated from their corresponding triggers.

First step would be to link variable v1 with v1c, and so on. (Not sure how I do that), but more importantly

Is there a way to sort the variables v1c,v2c,v3c based on their. count and then have a text box output them in this format: (assuming v2c>v1c>v3c)
OUTPUT:
v2 : v2c
v1 : v1c
v3 : v3c

ie, sort the variables and have an output. 

PS. I know reload or dynamic update works, but I cannot use that because of issues in their web version / published doc. Is there a formula- based approach to do this ?

Thank you !

Labels (1)
6 Replies
sunny_talwar

I think this is doable, but it is difficult to know what you have right now... are you able to share a sample where we can see what you have an suggest changes?

padmanabhv
Contributor III
Contributor III
Author

@sunny_talwar 

Attached a sample. Data, with 4 columns, id, sex, race, ethnicity.

Text box shows count, and I have triggers set up for each field.

Need to sort said text box in descending order.

sunny_talwar

When I select F in sex, I get this

Capture.png

What would be the sort order you would need?

 

padmanabhv
Contributor III
Contributor III
Author

The text box (just for display) has sex, race and ethnicity in that order,
But say the user chose Race, eth then sex, then the counts would be (for example), black = 4, no = 3, F = 3
IN that case I want it to display it in descending order:

black = 4,
no = 3,
F = 3

(I originally wanted it in order of user selection, but given it will always be in descending order, I can live with just sorting said variables)

sunny_talwar

Try this

=If(vSexCount >= vRaceCount and vSexCount >= vEthCount, vSex & ' = ' & vSexCount,
	If(vRaceCount >= vSexCount and vRaceCount >= vEthCount, vRace & ' = ' & vRaceCount, vEth & ' = ' & vEthCount))
& Chr(10) &
If(vSexCount >= vRaceCount and vSexCount >= vEthCount and vRaceCount > vEthCount, vRace & ' = ' & vRaceCount,
	If(vRaceCount >= vSexCount and vRaceCount >= vEthCount and vSexCount > vEthCount, vSex & ' = ' & vSexCount, vEth & ' = ' & vEthCount))
& Chr(10) &
If(vSexCount <= vRaceCount and vSexCount <= vEthCount, vSex & ' = ' & vSexCount,
	If(vRaceCount <= vSexCount and vRaceCount <= vEthCount, vRace & ' = ' & vRaceCount, vEth & ' = ' & vEthCount))
padmanabhv
Contributor III
Contributor III
Author

@sunny_talwar Appreciate the help, but in my actual case I have atleast 10 such fields (possibly could go up in the future). These conditions would get super messy.


I had a method to reload the script and add these variables into a table with fields as rows and the field value and count being the columns.
But I have issues with reload not working in a published qlikview document, and do not want to go down that path.