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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
mlarruda
Creator II
Creator II

How can I build a table about how many times a given value has a common feature with others?

Well, I have a table like this:

Day of WorkWorker
MondayAdam
MondayBob
MondayCarl
TuesdayAdam
TuesdayCarl
TuesdayDan
TuesdayEmma
WednesdayBob
WednesdayCarl
WednesdayDan
ThursdayBob
ThursdayEmma
ThursdayFred
FridayBob
FridayCarl
FridayEmma
FridayFred

And I want to know how many days each Worker worked with Adam, i. e., I want to obtain a table like that:

WorkerDays
Bob1
Carl2
Dan1
Emma2
Fred1

Anyone can help me? Many thanks in advance.

19 Replies
mlarruda
Creator II
Creator II
Author

I tested and it worked both with and without the "1" but still has some problems: my real database has thousands of registers and a bit more variables. And, for example, Adam has worked 417 times with Ben in 2017 and 5 times with Carl in 2016.

So, when I filter by clicking in year = 2016, the table shows Carl and 5.

When I filter by clicking in year = 2017, the table shows Ben and 417.


BUT, when I do not filter (and, so, am considering all years), the table shows only Carl and 5 instead of both rows. Can you say me why is it happening?

MK_QSL
MVP
MVP

Provide exact expression which you are using in your actual application.

mlarruda
Creator II
Creator II
Author

Count({<NAME -= {'Adam'},WORKDAY = P({1<NAME = {'Adam'}>}WORKDAY)>}Distinct WORKDAY)

MK_QSL
MVP
MVP

Can you provide sample app or sample data along with Year so that I can work on it?

mlarruda
Creator II
Creator II
Author

Sure. Here follows a sample data of 32 rows:

  

YEARWORKDAYNAME
2017Day01Adam
2017Day01Ben
2017Day02Adam
2017Day02Ben
2016Day03Adam
2016Day03Ben
2016Day04Adam
2016Day04Ben
2017Day05Adam
2017Day05Ben
2016Day06Adam
2016Day07Adam
2016Day07Ben
2016Day08Adam
2016Day08Ben
2016Day09Adam
2016Day10Adam
2016Day10Carl
2016Day11Ben
2016Day12Ben
2016Day13Ben
2016Day14Ben
2016Day15Ben
2016Day16Ben
2016Day17Ben
2016Day18Carl
2017Day19Carl
2017Day20Carl
2017Day21Carl
2017Day22Carl
2017Day23Carl
2017Day24Carl

As you can see, Adam worked:

* Three days with Ben in 2017 (Days 01, 02 and 05)

* Four days with Ben in 2016 (Days 03, 04, 07 and 08)

* One day with Carl in 2016 (Day 10)

I'm using the formula

Count({<NAME -= {'Adam'},WORKDAY = P({1<NAME = {'Adam'}>}WORKDAY)>}Distinct WORKDAY)

And getting the following results:

Adam01.PNGAdam02.PNGAdam03.PNG

Many thanks in advance for any solution you can find.

MK_QSL
MVP
MVP

Let me revise what you want?

For your sample data..

When you select 2016, you need Ben 4 and Carl 1

When you select 2017, you need Ben 3

When you not select any year, Ben 7 and Carl 1

Correct me if I am wrong !!

if this is what you need,

use below expression

Count({<NAME -= {'Adam'},WORKDAY = P({1<NAME = {'Adam'}>}WORKDAY)>}Distinct WORKDAY)

MK_QSL
MVP
MVP

QVW attached for your reference...

mlarruda
Creator II
Creator II
Author

Thanks! It is exactly what I want, but this expression is the same I am already using and that generated the screens above.

mlarruda
Creator II
Creator II
Author

Sorry, but I can't open this qvw:

mensagem.PNG

Google translation: "This QlikView document was created by another QlikView Personal Edition user. Since you are using QlikView Personal Edition, you can only open files that you have created yourself. You can recover the file if you have created it on another computer, but doing so will use one of your remaining 4 recovery attempts.


However, if you recover the file, you can no longer open files created with your current user key.


Do you want to continue and recover the file?"

mlarruda
Creator II
Creator II
Author

Well, I solved the problem. It was a big silliness of me.

Note that, in the screens I posted before, the resulting table has (I don't know why) only one row. But now I noted it and dragged the bottom margin, showing the 2nd row, showing the correct numbers.

So, many thanks for all and sorry for my silliness.