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: 
yashcena
Contributor III
Contributor III

Get Selected Count

Hi,

I have Project_Type and the Projected_Hours for those project types in my data model.

Capture.JPG

Capture2.JPG

I have a requirement where the user will select n number of  projects.

In the below snapshot, I have select 3 TypeA projects. So hours used when a resource is assigned those 3 projects will be 3*2=6 hours. So remaining hours for that resource will be 40-6=34 (Assuming each resource works 40 hours a week).

Capture3.JPG

Similarly, If 2 TypeB project are selected, hours used when a resource is assigned  projects will be 2*6=12 hours. So remaining hours for that resource will be 40-12=28

Capture3.JPG

In the above example, I have select 2,3 projects from SAME project types. But the user can select projects from different Project_Types.

In that scenario, what should be the expression? The expression which I have used to calculate Hours Used is (GetSelectedCount([Project Name])*[Projected Hours])

Capture3.JPG

However, this works only when the ProjectType is same. When I select 1 project of TypeA and 3 projects of TypeC, the expression fails.

How should I tweak my expression?

I hope I have made the requirement clear. Any help is appreciated.

Thanks,

YASH

1 Solution

Accepted Solutions
Or
MVP
MVP

There may be cleaner ways to do this, but since your tables aren't actually joined in any way, I'd use aggr().

sum(total aggr(sum( [Projected Hours])*count(distinct  [Project Name]),[Project Type]))

View solution in original post

5 Replies
Or
MVP
MVP

There may be cleaner ways to do this, but since your tables aren't actually joined in any way, I'd use aggr().

sum(total aggr(sum( [Projected Hours])*count(distinct  [Project Name]),[Project Type]))

yashcena
Contributor III
Contributor III
Author

Thanks! this expression worked perfectly.

I have one more question. I also need to give user the ability to enter the number of projects of a particular type

(I'm using slider for user input).

I created 3 variables vTypeA, vTypeB and vTypeC and put there sum in another variable vAll.

However, there seems to be something which I'm missing. I have selected 1 project of each type through slider.

But instead of calculating (2x1)+(6x1)+(10x1), it is calculating (2+6+10)*3

Capture3.JPG

Is there a way to do this via sliders? I have attached the updated app with the variables.

Thanks for your help again. Appreciate a lot!

Yash

Or
MVP
MVP

Nothing is attached..

yashcena
Contributor III
Contributor III
Author

I have attached the pp in the question itself.

Or
MVP
MVP

Unfortunately, it's hard to debug a formula I can't see, so a screen capture doesn't help here.