Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
Qlik Community Office Hours: Join us on July 9th, 2025 - REGISTER HERE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

If works, set analysis doesn't?

Hi All,

I was wondering if anyone might be able to shed a little light onto something I don't understand.  I have a fairly simple formula:

if([Rate Type] = 'DCS', [Comm TCV] * [Rep Comm Rate %])

This works in my straight table.  However this does not:

=SUM({$<[Rate Type] = {'DCS'}>}[Comm TCV] * [Rep Comm Rate %])

It only returns zeros.  I was just curious if there was some reason why it may not work.

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Edited reply:

Scratch that.  I see that I have [Comm TCV] both in the script, as well as an expression label.  So the problem is with the script and the math functions that are there.

.

View solution in original post

12 Replies
MK_QSL
MVP
MVP

Not sure but you can try below

=SUM({$<[Rate Type] = {'DCS'}>}([Comm TCV] * [Rep Comm Rate %]))


Which is equal to

SUM(if([Rate Type] = 'DCS', [Comm TCV] * [Rep Comm Rate %]))


or provide your sample data file or application..

Anonymous
Not applicable
Author

I would suggest you to try like this;


=SUM({$<[Rate Type] = {'DCS'}>}[Comm TCV])*[Rep Comm Rate %]


Regards,

Imran K

Anonymous
Not applicable
Author

Hi Dan,

May be:

=SUM({<[Rate Type] = {'DCS'}>}[Comm TCV] * [Rep Comm Rate %])

or

=SUM({<[Rate Type] = {'DCS'}>}([Comm TCV] * [Rep Comm Rate %]))

or

=SUM(if([Rate Type] = 'DCS', [Comm TCV] * [Rep Comm Rate %]))


Not applicable
Author

Hi Dan,

what are [Comm TCV] and  [Rep Comm Rate %] and [Rate Type] ,

are they  expressions label, or a filed name.




Anonymous
Not applicable
Author

There are some negative values in the [Comm TCV] field.  Doesn't seem to matter which method I use to write the Set Analysis, it ends up multiplying only the negative values. 

Anonymous
Not applicable
Author

Edited reply:

Scratch that.  I see that I have [Comm TCV] both in the script, as well as an expression label.  So the problem is with the script and the math functions that are there.

.

swuehl
MVP
MVP

You are not giving much information about the context of your expression and your data model. For example, you are using this expression in a straight table chart, but with what dimensions used?

In general, consider using aggregation functions (talking about your first expression):

Use Aggregation Functions!

I can't really tell why your second expression returns only zero (or negative values also?), so any more details about your data, model and expression context probably will help.

Anonymous
Not applicable
Author

I understand.  I couldn't really upload the file this time as it relates to internal employee compensation.  I believe that I have found the issue as part of the script.  I have to find a way to add two multiplied values. The following was only calculating the second part.

Alt([MRR] * Term_Flag) + Alt([Churn MRR] * Term_Flag)   AS [Comm TCV]

So the Alt([MRR] * Term_Flag)  is actually being excluded.

swuehl
MVP
MVP

Which means that [MRR] * Term_Flag doesn't return a numeric value for these records then.

Both fields numeric and within the input data record set?

Note: IMHO, Alt() with just a single argument (e.g. no default additional numeric to fall back to or an error value) is not making much more sense then just the single argument alone.