Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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.

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

Create a Straight Table

Dimension

Worker

Expression

Count({<Worker -= {'Adam'},[Day of Work] = P({1<Worker = {'Adam'}>}[Day of Work])>}Distinct [Day of Work])

Capture.JPG

View solution in original post

19 Replies
MK_QSL
MVP
MVP

Do you want to achieve this at script level or at front end?

mlarruda
Creator II
Creator II
Author

Sorry, I don't know what is Front End, but I wished something I could use directly in the table building.

However, if this is possible only in the same script i use to read the data, then I can go for it.

MK_QSL
MVP
MVP

How Emma has worked 2 days with Adam?

mlarruda
Creator II
Creator II
Author

Sorry, in copying the table from Excel something went wrong. The correct output table would be:

Bob - 1

Carl - 2

Dan - 1

Emma - 1

MK_QSL
MVP
MVP

Create a Straight Table

Dimension

Worker

Expression

Count({<Worker -= {'Adam'},[Day of Work] = P({1<Worker = {'Adam'}>}[Day of Work])>}Distinct [Day of Work])

Capture.JPG

mlarruda
Creator II
Creator II
Author

WORKED, with a small correction:

Count({<Worker -= {'Adam'},[Day of Work] = P({1<Worker = {'Adam'}>}[Day of Work])>}Distinct [Day of Work])

This 1, after "P({", seems to be a type error.

Thanks a lot!

MK_QSL
MVP
MVP

This is not a type error...

1 will make sure that when something selected then the inner set expression will ignore that selection and you will still get Day or Work for Adam.

Also, if you got your answer then kindly close the thread by selecting correct answer.

mlarruda
Creator II
Creator II
Author

Thank you, but for me the script didn't work with this 1.

MK_QSL
MVP
MVP

Please check that you have write it correctly and no syntax error !!