Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.

Turn on suggestions

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

Showing results for

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

Showing results for

- Qlik Community
- :
- Forums
- :
- Analytics
- :
- New to Qlik Analytics
- :
- Re: Adding Pivot Table Total in Qlik Sense

Options

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

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

Showing results for

gisellevaleta

Contributor III

2021-06-04
07:07 PM

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

Adding Pivot Table Total in Qlik Sense

My Conversion Rate Calc is as follows:

Sum(Transactions)/Sum(Average Visitors)

I have the below conditions that state if Conversiion Rate Calc is null then null and if its between 10% and 60% then return the Conversion Rate else make it zero

If(IsNull(Sum(Transactions)/Sum([Average visitors])), 0,

If((Sum(Transactions)/Sum([Average visitors]))>0.6, 0,

If((Sum(Transactions)/Sum([Average visitors]))>0.1, (Sum(Transactions)/Sum([Average visitors])))))

The result is correct for each store but the total is not correct

1018665/3060186=33,3% and not 26563,8%

I've tried this expression but it's not working

Sum(Aggr((If(IsNull(Sum(Transactions)/Sum([Average visitors])), 0,

If((Sum(Transactions)/Sum([Average visitors]))>0.6, 0,

If((Sum(Transactions)/Sum([Average visitors]))>0.1, (Sum(Transactions)/Sum([Average visitors])),0)))), Store, Date))

This works for the rows but it's not giving the correct total.

1 Solution

Accepted Solutions

rubenmarin

MVP

2021-06-05
11:36 AM

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

Hi, instead of a sum of the percentages you need a sum of each of the values separatedly and then calcualte the percentage, something like:

```
Sum(Aggr((If(IsNull(Sum(Transactions)/Sum([Average visitors])), 0,
If((Sum(Transactions)/Sum([Average visitors]))>0.6, 0,
If((Sum(Transactions)/Sum([Average visitors]))>0.1, (Sum(Transactions)),0)))), Store, Date))
/
Sum(Aggr((If(IsNull(Sum(Transactions)/Sum([Average visitors])), 0,
If((Sum(Transactions)/Sum([Average visitors]))>0.6, 0,
If((Sum(Transactions)/Sum([Average visitors]))>0.1, (Sum([Average visitors])),0)))), Store, Date))
```

If in script you flag records by Store and date where they accomplish that Sum(Transactions)/Sum([Average visitors])>0.1 and <0.6, you will only need:

`Sum({<flagField={1}>} Transactions)/Sum({<flagField={1}>} [Average visitors])`

And this will work for rows and for totals, with better performance than using aggr.

5 Replies

rubenmarin

MVP

2021-06-05
04:38 AM

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

Hi, in this case you don't have to use aggr because it will sum each percentage. I don't see why the first expression will return that high %, it should work using the same expression as by store. Is that result with just the first expression or with the aggr applied?

Other expression may be needed if youwant to exclude some stores in the total row

gisellevaleta

Contributor III

2021-06-05
04:53 AM

Author

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

Hi, I need the second expression to work as I am excluding some stores in the total. The second expression is giving me the high%

870 Views

MayilVahanan

MVP

2021-06-05
10:19 AM

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

Can you please share the sample app?

Thanks & Regards, Mayil Vahanan R

Please close the thread by marking correct answer & give likes if you like the post.

Please close the thread by marking correct answer & give likes if you like the post.

849 Views

rubenmarin

MVP

2021-06-05
11:36 AM

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

Hi, instead of a sum of the percentages you need a sum of each of the values separatedly and then calcualte the percentage, something like:

```
Sum(Aggr((If(IsNull(Sum(Transactions)/Sum([Average visitors])), 0,
If((Sum(Transactions)/Sum([Average visitors]))>0.6, 0,
If((Sum(Transactions)/Sum([Average visitors]))>0.1, (Sum(Transactions)),0)))), Store, Date))
/
Sum(Aggr((If(IsNull(Sum(Transactions)/Sum([Average visitors])), 0,
If((Sum(Transactions)/Sum([Average visitors]))>0.6, 0,
If((Sum(Transactions)/Sum([Average visitors]))>0.1, (Sum([Average visitors])),0)))), Store, Date))
```

If in script you flag records by Store and date where they accomplish that Sum(Transactions)/Sum([Average visitors])>0.1 and <0.6, you will only need:

`Sum({<flagField={1}>} Transactions)/Sum({<flagField={1}>} [Average visitors])`

And this will work for rows and for totals, with better performance than using aggr.

gisellevaleta

Contributor III

2021-06-06
05:30 AM

Author

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

This worked perfectly, thank you.

824 Views

Community Browser