Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
plexpro52
Creator
Creator

How to base set selection on another field when based-on field has no selection specified

I am attempting to restrict use of a numeric field by values for a related date, if a value for another date have been selected, but if no selection exist for that referenced date field, then selection for the related date field should be ignored.

count({$<RunStart_YrMo_num=RunStart_YrMo_PMCells>}distinct serial_number)

Thus, if the user have selected a value for "RunStart_YrMo_PMCells", and there be "serial_number" values for that value in the date field "RunStart_YrMo_num" that is related to "serial_number", I get results.

However, if the user have not specified any selection for "RunStart_YrMo_PMCells", I want there to be no constraint.  The code above returns nothing in this case, rather than everything.

René V.

4 Replies
PriyankaShivhare
Creator II
Creator II

count({$<serial_number={"=RunStart_YrMo_num=RunStart_YrMo_PMCells"}>}distinct serial_number)

 

i didnt understand the requirement. but may be this is what u want to try.... 

The format of RunStart_YrMo_num and RunStart_YrMo_PMCells should be same

if RunStart_YrMo_num is in num then RunStart_YrMo_PMCells should also be num.

thanks,

Priyanka

Rodj
Luminary Alumni
Luminary Alumni

There's probably a few ways to do this, including the associative search solution  @PriyankaShivhare has shown you.

Another way is to include some logic:

if(GetSelectedCount(RunStart_YrMo_PMCells) > 0,
    count({$ <RunStart_YrMo_num = {$(GetFieldSelections(RunStart_YrMo_PMCells))}>} distinct serial_number),
    count(distinct serial_number)
)

This way if you need to convert the format of the data in some way you can include that in the result of GetFieldSelections.

You could perhaps also try using the intersection operator and an "element function":

count({$ <RunStart_YrMo_num *= P(RunStart_YrMo_PMCells)}> } distinct serial_number)

 

You'll see solutions like this if you search for terms such as "using a data island to limit set analysis"

Alternatively, the way you have described the problem suggests you have a data island in your model and you may want to consider changing the model to associate the RunStart_YrMo_PMCells field.

 

plexpro52
Creator
Creator
Author

Priyanka,

Thanks for your response, this would appear to be the start of a solution, but I haven't quite resolved it yet.

René

plexpro52
Creator
Creator
Author

Rodj,

Thanks for your response, this appears promising, but I haven't quite resolved it yet.

René