Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum expression in Table chart

Hello, I'm having trouble writing a expression for the next situation:

In a table chart, i have my periods (month - year), and the customers.

I want to add a column that have the percentage of sales by customer according to the total of sales o the month.

This is how I'm doing in:

- Add the two dimensions (period, client)

- Get the sales of the customer ( sum(Sales) )

- Get the total sales of the month ( sum({$<Client=>}Sales)

But the values i'm getting aren't the correct. The problem is getting the correct sum of sales of the month.

Any ideas of how to write the expression?

Thank you

1 Solution

Accepted Solutions
swuehl
MVP
MVP

I think this should work. You need to use the correct field name with the TOTAL qualifier, and field names are case sensitive in QV. If your dimension field is period, use

=sum(TOTAL<period> Sales)

So

=sum(Sales) / sum(TOTAL<period> Sales)

should give you the percentage of Sales for a given Client and given period compared with the total sales for that period across all Clients.

View solution in original post

6 Replies
swuehl
MVP
MVP

Try a TOTAL qualifer, like

=sum(TOTAL<Client> Sales)

edit: ah, sorry, you probably need


=sum(TOTAL<Month> Sales)


Not applicable
Author

I added that, but i got the total of all periods, not the total per period.

Thanks

swuehl
MVP
MVP

I think this should work. You need to use the correct field name with the TOTAL qualifier, and field names are case sensitive in QV. If your dimension field is period, use

=sum(TOTAL<period> Sales)

So

=sum(Sales) / sum(TOTAL<period> Sales)

should give you the percentage of Sales for a given Client and given period compared with the total sales for that period across all Clients.

Not applicable
Author

Yes, you're correct, it's working now, also i was using {} thinking it was set analysis.

Other question, this would work with dimensions created by expressions?

thank you

Not applicable
Author

I mean, a calculated dimension.

swuehl
MVP
MVP

No, I think you are able to use field names only with the TOTAL qualifier.

If possible, create a field in the script to replace the calculated dimension with a field.