
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Compute proportion between two tables
Hi,
I am working on Qlik Sense and looking for a way to compute the proportion of equal data between two tables.
For example, let's assume we have two sales tables, Sales A and Sales B, which are the number of sold items A and B day by day during 5 years.
Do you know a way to compute the proportion of days where we have sold the same amount of items A and B ?


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Eleyeh,
Can you attached sample data file .
Thanks,
Mukram

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mukram,
Here's a data sample :
Sales A | Sales B |
---|---|
1 | 1 |
4 | 2 |
5 | 3 |
9 | 4 |
15 | 15 |
11 | 11 |
3 | 4 |
12 | 18 |
0 | 4 |
1 | 1 |
8 | 7 |
So in this example each table has 11 lines and 4 lines have equal values in both columns. So the desired output should be 4/11


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try as below
TableA:
LOAD [Sales A] , Rowno() as RowKEY
FROM
[https://community.qlik.com/thread/274005]
(html, codepage is 1252, embedded labels, table is @1);
TableB:
LOAD
[Sales B] , Rowno() as RowKEY
FROM
[https://community.qlik.com/thread/274005]
(html, codepage is 1252, embedded labels, table is @1);
now create a straight table with dimensions
RowKEY, Sales A , Sales B
add below expression
sum(if([Sales A]=[Sales B],1))
or in a textbox
=sum(if([Sales A]=[Sales B],1)) & ' / ' & count(DISTINCT RowKEY) /// string 4 / 11
or
=sum(if([Sales A]=[Sales B],1)) / count(DISTINCT RowKEY) // Percentage 4 / 11
can you provide something that closely matches the dataset you are working with?
If a post helps to resolve your issue, please accept it as a Solution.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Eleyeh,
As you mentioned in your first comment you have two tables
How those Two Tables are Connected with each other ? (Based on Date ).
IF based on Date field then we can create a flag in the backend to check on each date SAELS A and SALES B if
both are Equal then flag value 1 else 0 and we can use that flag in the front end.
if you can share your sample data with the same structure it will good for us to help you in better way.
Thanks,
Mukram.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Vineeth and Mukram for you answers !
I am sorry but I unfortunately can't give a sample of the data I work with. However I can give more details about my dataset. So Sales A and Sales B are two tables that are loaded separately from the database. Each tables has two columns : one with the quantity of sales per day and another column with the date the sales are made. So the tables are connected by the date. The rest of it really similar to the example I've given.
Thanks again for you answers, I will try them tomorrow !


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We don't need a real sample of your data!
But you can create dummy data that represents your dataset.
If a post helps to resolve your issue, please accept it as a Solution.
