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

set analysis (aggr)

hi i have this table-

projectunitactualbudget
Aaa90
Abb54
Baa52
Cbb26
Cff40
Ccc24
Dbb00
Faa29

i need an taxt box that will count the number of projects that have at least one unit that have actual and dont have budget

in our case 2 projects - A,C

How should i write the expression?

adi

1 Solution

Accepted Solutions
sunny_talwar

Without script manipulations, you can try this:

=Count(DISTINCT Aggr(If(Sum(actual) > 0 and Sum(budget) = 0, project), project, unit))

View solution in original post

6 Replies
karthickv
Partner - Creator
Partner - Creator

Hi Adi,

For your example with the below expression:

sum( aggr(if(sum(actuals)>0 and sum(budget)=0,1,0),Project,Unit))


Incase if there are more than one Unit with budget as zero and you still want to count only projects try to use the below:

sum(aggr( if(sum(aggr(if(sum(actuals)>0 and sum(budget)=0,1,0),Project,Unit) ))>0,1,0),Project))

Regards,

Karthick.

sunny_talwar

Try this script:

Table:

LOAD project,

    unit,

    actual,

    budget,

    AutoNumber(project&unit) as Key

FROM

[https://community.qlik.com/thread/219558]

(html, codepage is 1252, embedded labels, table is @1);

Text box expression:

=Count(DISTINCT {<Key = {"=Sum(actual) > 0 and Sum(budget) = 0"}>} project)

Capture.PNG

sunny_talwar

Without script manipulations, you can try this:

=Count(DISTINCT Aggr(If(Sum(actual) > 0 and Sum(budget) = 0, project), project, unit))

adiarnon
Creator III
Creator III
Author

its working!

but the calculation taking a very long time

do you have any idea how can i do it more efficient? ( quickly)

adi

antoniotiman
Master III
Master III

Hi Adi,

have You tried without Aggr(), simply

Count({<actual-={0},budget={0}>} DISTINCT project)

Regards,

Antonio

sunny_talwar

I did provide a quicker solution where you would have to create a Key field in the script. You should see performance benefits if you are able to and are willing to do it.


Best,

Sunny