Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
midnight1
Contributor II
Contributor II

How to calculate a percent of income

Hi everyone 🙂

I have data about shops from different cities and about invoices. Products in those shops have 7-digits codes. Invoices for those products can by invoiced in two ways (directly or blurred) depending on the 7-digits code. So it looks like this:

Zrzut ekranu 2024-11-25 115014.pngnrSklep is the number of the particular shop 

I've marked rows to show that it can be more clear --> for a products with the same "code 7", the shop has direct and indirect invoices. 
I want to have a column with a percentage of these two types of invoices for each code7, for each shop, for each month/year.
If I won't add "invoiced by" and add a measure sum(invoice value), I get the overall value:

midnight1_0-1732532814028.png

I tried something like this:
=((Aggr(distinct sum(invoice value), year, month, nrSklep, code7, invoiced by))
/
(Aggr(nodistinct sum(invoice value), year, month, nrSklep, code7)))*100

and it works:

midnight1_1-1732533260140.png

BUT: when i filter "direct" i want it to show me only direct invoices values and % they are but it change to this:
% is 100 for everything

midnight1_2-1732533336080.png

How can i filter by direct/indirect and still get the correct % ?




Labels (4)
1 Solution

Accepted Solutions
Taofeekat
Contributor II
Contributor II

Try 

((Aggr(distinct sum(invoice value), year, month, nrSklep, code7, invoiced by))
/
(Aggr(nodistinct sum({$<invoiced by=>} invoice value), year, month, nrSklep, code7)))*100




View solution in original post

1 Reply
Taofeekat
Contributor II
Contributor II

Try 

((Aggr(distinct sum(invoice value), year, month, nrSklep, code7, invoiced by))
/
(Aggr(nodistinct sum({$<invoiced by=>} invoice value), year, month, nrSklep, code7)))*100