Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Sazabi
Creator
Creator

Counting the number of objects that have passed a threshold per day?

Salutations Qliksters!

 

I have a measure: sum(a)/sum(b)

 

I want to count how many objects, per day and in a table, have crossed a defined threshold.

I can get what I want with an if statement, but it is slow. Is there any way to write a set analysis expression to do this?

 

sum(aggr(if((sum(a) / sum(b)) < 1000, 1, 0),OBJECT, timestampDate))

Sazabi_0-1627430047734.png

 

 

Regards,

 

 

 

 

S

 

 

1 Reply
stevejoyce
Specialist II
Specialist II

Can you create an aggregate table in your data model:

 

aggr_object_date:

  load

    timestampDate

  ,OBJECT

  ,if((sum(a) / sum(b)) < 1000, 1, 0) as ThresholdFlag_Date_Object

resident <table>

group by 

    timestampDate

  ,OBJECT

;

 

create and join by composite key (timeStampDate & '-' & timestampDate)

 

or if you only need by date...

aggr_date:

  timestampDate

  ,sum(MeasureFlag) as ThresholdFlag_Date

resident aggr_object_date

  group by timestampDate

;

 

drop table aggr_object_date;

 

and front-end would just be: sum(ThresholdFlag_Date)