Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Showing results for

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

- Qlik Community
- :
- Forums
- :
- Analytics
- :
- New to Qlik Sense
- :
- Re: SUM the output of the expression

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Showing results for

Sara_3

Contributor III

2022-07-27
10:16 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

SUM the output of the expression

I have a Output weeks column and the set Analysis is below :

Output Weeks |

12 |

12 |

Set Analysis:

only( { < [Category Type]= {'1'}, Output_Weeks= { "=max({<[Category Type]= {'1'}>} [Deadline Date])< Min({<[Category Type]= {'1'}>}[Creation Date])

AND min({<[Category Type]= {'1'}>} [Creation Date]) < Min ({<[Category Type]= {'1'}>}[Binding Date])" } > }Output_Weeks )

when I replaced the ONLY to SUM I got some random value.

Requirement:

need to SUM of the above set analysis means the output should be 12+12 = **24** in the KPI or Text box.

Thanks.

439 Views

7 Replies

Or

MVP

2022-07-27
10:56 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

As you already tried, if you want the values to be summed you need to use sum() rather than Only(). If the result is not what you expect, this is likely because the underlying values are not what you provided and there are actually more than just these two rows. I'd suggest checking your source to ensure that it does in fact consist of what you expect. You could also troubleshoot by replacing the Only() with Count() - this will tell you how many underlying rows you're actually reading from, and if that number isn't two, there's probably some form of duplication.

Sara_3

Contributor III

2022-07-27
11:16 AM

Author

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

thanks , when I used COUNT it gave me 50 for each like 50 + 50 = 100.

415 Views

Sara_3

Contributor III

2022-07-27
11:22 AM

Author

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

is there another way to do this ?

412 Views

Or

MVP

2022-07-28
03:57 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Iif your data is actually two rows, both have a value of 12, and you use sum, you'll get a result of 24. If you are getting a different result, then your underlying data is not actually two rows of 12, but I have no way of knowing what it is you might be dealing with because in your sample data, it's just two rows of 12. As I suggested, you could use Count() to see if there's more than two rows, and you could use Concat() instead of Only() to get a list of all the values that are being included in this calculation.

392 Views

Sara_3

Contributor III

2022-07-29
09:03 AM

Author

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Thanks!

375 Views

PrashantSangle

MVP

2022-07-29
10:40 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

did you try with distinct

like Sum(**distinct** yourexpression)

or try with AGGR()

like SUM(AGGR(yourExpression,dimesion_which_you_have_in_chart))

Regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.

369 Views

Sara_3

Contributor III

2022-07-29
11:25 AM

Author

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Yes, I tried SUM with distinct and aggr() , in both cases I got 12.

Aggr expression:

sum(aggr(only( { < [Category Type]= {'1'}, Output_Weeks= { "=max({<[Category Type]= {'1'}>} [Deadline Date])< Min({<[Category Type]= {'1'}>}[Creation Date])

AND min({<[Category Type]= {'1'}>} [Creation Date]) < Min ({<[Category Type]= {'1'}>}[Binding Date])" } > }Output_Weeks ), Output_Weeks))

Thanks.

365 Views