Qlik Community

Ask a Question

New to Qlik Sense

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

Announcements
Become an analytics expert with Qlik's new 15 week course: Applied Data Analytics using Qlik Sense. READ MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
gisellevaleta
Contributor III
Contributor III

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.

@sunny_talwar 

@MayilVahanan 

 

1 Solution

Accepted Solutions
rubenmarin

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.

View solution in original post

5 Replies
rubenmarin

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
Contributor III
Author

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%

MayilVahanan

HI @gisellevaleta 

Can you please share the sample app?

Thanks & Regards,
Mayil Vahanan R
rubenmarin

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.

View solution in original post

gisellevaleta
Contributor III
Contributor III
Author

This worked perfectly, thank you.