Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
jduluc12
Creator
Creator

=Concat(DISTINCT [ID], ',' ) is not working all the time

Hi,

I am using "=Concat(DISTINCT [ID], ',' )" to fetch the possible values from a list box and store it in a variable but sometimes it returns all the values from the list box.  If I just open and close the expression for the variable then it again shows the correct value. 

It is not very reliable. Is there any way to fix it?

Thanks,

Jean

Labels (1)
6 Replies
marcus_sommer

Expressions within a variable work usually well as far as they aren't used to trigger anything because it would require that the variable is always re-calculated but not each user-action triggers such re-calculation and/or it might happens in the wrong order because the various calculations within the sheet aren't sequentially aligned else they are executed in multithreading and are rather unpredictably.

In your case it could be that the variable is calculated before the selection is released or between releasing and the new set values or ...

But in many cases this is not a real problem because the detour with the variable isn't necessary and expressions like your: Concat(DISTINCT [ID], ',' ) could be applied directly within the actions or expressions or they might be also replaced with a set analysis like: {< ID = p(ID)>}

- Marcus

jduluc12
Creator
Creator
Author

Hi Marcus,

Thanks for the reply.

I was using variables because i  am using the selection of one field from one alternate state to select something else in the other alternate state.

=concat({One} DISTINCT if (match([ID], $(v3)) and not isnull([ ID]) , chr(39) & [Lot] & chr(39)) ,',') 

the v3 is defined as "=Concat(DISTINCT [ID], ',' )"

Jean

marcus_sommer

I think you could use for it:

=concat({One} DISTINCT if (match([ID], $(=Concat(DISTINCT [ID], ',' ))) and not isnull([ ID]) , chr(39) & [Lot] & chr(39)) ,',') 

- Marcus

jduluc12
Creator
Creator
Author

Hi Marcus,

I will certainly try that.

For now, I just ended up using getpossiblevalues() Marco and it is working fine.

But it is good to know that the expression within $(=) has its own alternate state.

jduluc12
Creator
Creator
Author

So I am trying to use the following expression as my dimension of a chart which belongs to alt state "One" and I am getting an error. 

=if (match([Lot], $(concat({One} DISTINCT if (match([ID], (Concat(DISTINCT [ID], ',' )))
and not isnull([ID]) , chr(39) & [Lot ]& chr(39)) ,','))), [Lot])

I think I should be using

=if (match([Lot], $(concat(DISTINCT if (match([ID], (Concat{"Inherit State"}(DISTINCT [ID], ',' ))) 
and not isnull([ID]) , chr(39) & [Lot ]& chr(39)) ,','))), [Lot])

but i do not know what sign to use to indicate the "Inherit State".

Is there any?

marcus_sommer

It's not quite clear for me what do you want to do but I think getfieldselections() would be more suitable as concat() because with the fourth parameter you could specify the state which should be considered.

Beside this I think it could be completely done with set analysis which has also the capability to match multiple states. It won't be very easy but if you have multiple similar tasks it will be probably more practically as fetching the various selections with concat() or getfieldselections(). My experiences with states are quite limited because I have no usecases for it and therefore I couldn't give you an example but here (and there in the links at the bottom) you will find many explanations and examples to set analysis and a few are also related to states and should give you a good starting point for it: livingqlik-roots-the-ultimate-qlikview-set-analysis-reference

- Marcus