Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Marcushenriquesk

set analysis script not filtering intended conditions.

I have this script:

=avg(aggr({<[PANEL_ID]={"3000,4000,53501,50027,50031,50038,50039,50041,58001,59001"}>+<[PANEL_ID]={">=53001<=53027"}>+<[PANEL_ID]={">=50001<=50026"}>+<[PANEL_ID]={">=54001<=54012"}>+<[PANEL_ID]={">=52001<=52014"}>+<[PANEL_ID]={">=56001<=56005"}>+<[PANEL_ID]={">=53701<=53704"}>+<[PANEL_ID]={">=53801<=53806"}, [RUN_DATE_TIME]={"=[RUN_DATE_TIME]>=[RECEIVED_DATE_TIME]"}, PANEL_ID={'4000'}>}(RUN_DATE_TIME-RECEIVED_DATE_TIME)*24,ACC_ID))

 

The average is working, so is the run_date >=Received date, but as for the filters of panel_id, they are not working. debug says 'okay' so not sure what im doing wrong.

Labels (3)
4 Replies
stevejoyce
Specialist II
Specialist II

This is no good:

[PANEL_ID]={"3000,4000,53501,50027,50031,50038,50039,50041,58001,59001"}

is Panel_ID numeric?  then you don't need any quotes.

[PANEL_ID]={3000,4000,53501,50027,50031,50038,50039,50041,58001,59001}

 

if string then

[PANEL_ID]={'3000','4000','53501','50027','50031','50038','50039','50041','58001','59001'}

Marcushenriquesk
Author

neither method you listed worked, still failing to remove those panel codes.

Marcushenriquesk
Author

I also tried moving the set analysis before the aggregation but that didnt work either. im not sure why this is happening. is this a bug? i tried single, double and no quotes both on the inside of the aggr and outside. its so weird that the set analysis for the rundate works perfectly fine however.

marcus_sommer

I think there is no bug but it's not quite clear what do you want to filter and in which level? Why using an aggr? Why applying so many set analysis statements within an expression?

The normal logic would be:

avg({< >} value)

Multiple fields within it would be linked per AND and the field-values within {} are linked with OR.

if really a multi-layer aggregation is needed you might apply:

avg({< >} aggr(avg({< >} value), DimX))

More complex is it by multiple set analysis statements, like:

avg({< set1 > + < set2 > } value)

because here you need to define the operator (+ means OR) between the generally independent statements.

In your case I assume that's much more complicated as needed and you may use something like this:

avg({< Date = {anyDate}, ID = {'1', '2', ">=5<=10", '14', ">=20<=30", '555'}>} value)

This means you could write all the ID conditions within a single call.

- Marcus