Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Well, I have a table like this:
Day of Work | Worker |
---|---|
Monday | Adam |
Monday | Bob |
Monday | Carl |
Tuesday | Adam |
Tuesday | Carl |
Tuesday | Dan |
Tuesday | Emma |
Wednesday | Bob |
Wednesday | Carl |
Wednesday | Dan |
Thursday | Bob |
Thursday | Emma |
Thursday | Fred |
Friday | Bob |
Friday | Carl |
Friday | Emma |
Friday | Fred |
And I want to know how many days each Worker worked with Adam, i. e., I want to obtain a table like that:
Worker | Days |
---|---|
Bob | 1 |
Carl | 2 |
Dan | 1 |
Emma | 2 |
Fred | 1 |
Anyone can help me? Many thanks in advance.
Create a Straight Table
Dimension
Worker
Expression
Count({<Worker -= {'Adam'},[Day of Work] = P({1<Worker = {'Adam'}>}[Day of Work])>}Distinct [Day of Work])
Do you want to achieve this at script level or at front end?
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.
How Emma has worked 2 days with Adam?
Sorry, in copying the table from Excel something went wrong. The correct output table would be:
Bob - 1
Carl - 2
Dan - 1
Emma - 1
Create a Straight Table
Dimension
Worker
Expression
Count({<Worker -= {'Adam'},[Day of Work] = P({1<Worker = {'Adam'}>}[Day of Work])>}Distinct [Day of Work])
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!
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.
Thank you, but for me the script didn't work with this 1.
Please check that you have write it correctly and no syntax error !!