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

Combining two different conditions in set analysis

Hi all, 

I have a question regarding set analysis. 

I want to calculate a percentage of a sample from the total and display only data from previous year. 
As Total can't be 0, I want to prevent this. 

After a long research, I thought this should be working:

Sum({$<StatYear={$(=max(StatYear)-1)}>*<Total = {">0"}>} [Sample]/[Total])

While the formula seems ok regarding syntax, the output can't be correct, numbers are way too high. 
I can't imagine what's happening there and I don't know how to fix this. 

3 Replies
agigliotti
Partner - Champion
Partner - Champion

Hi @hppflpp ,

To me what you are trying to achieve it's not clear, could you post a sample app with mock data?

hppflpp
Contributor II
Contributor II
Author

Hi @agigliotti , of course.

What I want to do is: I want to calculate the percentage (Sample / Total) from previous year, but as Total can be 0 (it's not in my example, but in my original file), I want to prevent destroying mathematics by only picking those lines where Total is bigger than 0.

In this case by the way the equation shows 0. After restarting the file I'm actually working on, this also shows 0. What did I miss?

agigliotti
Partner - Champion
Partner - Champion

maybe this:

=Sum(Sample)
/
Sum( {< StatYear = {$(=max(StatYear)-1)} > TOTAL Sample )

I hope it can help.

Best Regards