Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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))
Regards,
S
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)