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: 
SP_Qlik
Contributor II
Contributor II

And / Or query implementation in set analysis

Hi,

Hope you are doing well!

I want to add below filter criteria into my set analysis which includes multiple And/or conditions. 

Can you please help me how to write set analysis for below query.

Measure: Count(ID's)

Filter Criteria:( ( Ind_Valid_Only
OR ( Ind_Valid_Only_With_PrivateData
AND Aff_Market_Access_Flag Equal Y
)
OR ( Ind_Status_cod Equal 9
AND Ind_Status_date Greater than_LastDayLast_Month
AND ( Aff_Private_Company Is Null
OR Aff_Market_Access_Flag Equal Y
)
)
)
AND Ind_Professional_Type_cod Equal M
AND Ind_Creation_date Less than or Equal to_LastDayLast_Month
)

Here I want to include my filter criteria into set analysis 

Thanks in advance.

Thanks,

SP

Labels (1)
3 Replies
Vegar
MVP
MVP

Set analysis might not be the best fit for this. It looks like an advanced rule. What if you pre calculate  this in the script.

If(( ( Ind_Valid_Only

OR ( Ind_Valid_Only_With_PrivateData

AND Aff_Market_Access_Flag Equal Y

)

OR ( Ind_Status_cod Equal 9

AND Ind_Status_date Greater than_LastDayLast_Month

AND ( Aff_Private_Company Is Null

OR Aff_Market_Access_Flag Equal Y

)

)

)

AND Ind_Professional_Type_cod Equal M

AND Ind_Creation_date Less than or Equal to_LastDayLast_Month

), 1, 0) as flag_field,

 

 

Then you could just use: count{<flag_field={1}>}ID)

SP_Qlik
Contributor II
Contributor II
Author

Hi Vegar,

Thanks for your prompt response.

Attributes I am using in this query are coming from different tables, hence its difficult to implement in script and also I have to implement similar queries for other metrics as well with different attributes.

Thanks,

SP

marcus_sommer

Does your data-model support this kind of query? NULL for example couldn't be directly queried and in the most scenarios it would be useful to replace them with real values in the script.

A quite quick check would be to use the count-expression without a condition and then selecting all wanted values in the appropriate fields. Are these selections possible and the count returned the expected results an appropriate set analysis statement would be possible. If not you could place all these fields within a table-box and playing again with the selections to see the existing relationships and data which would hint a few directions to adjust the data-model.