Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
josemaria_cabre
Contributor III
Contributor III

help with set analysis and function

Hi,

I use this function to get the 2nd selected value of field [Comp Name]

subfield(GetFieldSelections([Comp Name]),',',2)

I'd like to sum 'Amount' only of 2nd selected value, so I wrote this expression using set analysis:

sum({<[Comp Name]={'$(=SubField(GetFieldSelections([Comp Name]) ,',',2))'}>} Amount)

but it doesn't work

Same function with first selected value seems to work fine, I can't understand why

sum({<[Comp Name]={'$(=SubField(GetFieldSelections([Comp Name]) ,',',1))'}>} Amount)

I also tried to create a variable $(vSelComp2) that contains function subfield(GetFieldSelections([Comp Name]),',',2)

to use in this expression:

Sum({<
[Comp Name]={$(vSelComp2)}

>} Amount)

and it doesn't work either.

I need to sum amount of 2nd, 3rd, ... selected value only, but I can't get this to work. Any help would be appreciated.

Thanks in advance,

Jose

1 Solution

Accepted Solutions
sunny_talwar

Try this

Sum({<[Comp Name]={"$(=SubField(GetFieldSelections([Comp Name], '@'), '@', 2))"}>} Amount)

The issue was that your Comp Name included comma in the name which confused the SubField function. In order to fix this, I changed the delimiter for GetFieldSelections to @ (you can change this to anything which won't occur in the Comp Name field) and then used SubField with @.

Capture.PNG

HTH

Best,

Sunny

View solution in original post

4 Replies
sunny_talwar

Would you be able to share a sample which shows the issue?

josemaria_cabre
Contributor III
Contributor III
Author

Sure. I did this sample .qvf, hope it helps. You need to select (at least) 2 companies at Comp Name filter.

Thank you!

sunny_talwar

Try this

Sum({<[Comp Name]={"$(=SubField(GetFieldSelections([Comp Name], '@'), '@', 2))"}>} Amount)

The issue was that your Comp Name included comma in the name which confused the SubField function. In order to fix this, I changed the delimiter for GetFieldSelections to @ (you can change this to anything which won't occur in the Comp Name field) and then used SubField with @.

Capture.PNG

HTH

Best,

Sunny

josemaria_cabre
Contributor III
Contributor III
Author

Works great now. Thank you very much Sunny!

Best regards,
Jose.