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: 
Anonymous
Not applicable

How calculate a total

Hi all, 

I have  2 tables "consultation" et "bénéficiaire" and i want count the number of consultations per beneficiary.

I tried with this function 

(consultation.idBeneficiaire == beneficiaire.idBeneficiaire)? (NombreTotal = NombreTotal+1) : 0 

 

but i receive a message of error in figure 2.

 I hope receive your help for resolve my problem.

 

Thank you. 

 

Thank you for all.

Labels (2)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

Hi,

Did you get your solution?

Else, here is a new proposal:

0683p000009Lsbz.png

 

I have 2 tables:

- beneficiaire with an id and a name:

0683p000009Lsc9.png

- consultation with an idbeneficiaire:

0683p000009LsRw.png

The objective is to get the number of consultations for a beneficiaire.

So, the 2 tables are joined using a tMap with beneficiaire as the main table and consultation as the lookup table.

Before to join these 2 tables, I use a tAggregateRow to count the number of consultation records per beneficiaire (see previous answer to see the configuration for this component).

Here is the tMap:

0683p000009LsSA.png

And finally, the result:

0683p000009LscE.png

What else?

View solution in original post

14 Replies
TRF
Champion II
Champion II

tAggregateRow is here for that.
Try it on table consultation.
TRF
Champion II
Champion II

The pointer to the documentation in french 0683p000009MA9p.png https://help.talend.com/reader/tM3os~7PoPzBK28jtBNgCw/i_YvOl2oUaVpW1UTnJao_g
You need to go with the "count" function.
Let us know if you have some problem with it. Else you know how it works to close the case 0683p000009MA9p.png)
Anonymous
Not applicable
Author

Thank you.

i'll read it 0683p000009MACn.png

else i want don't find a problem because i must finish my OlapCube before 00:00 (time of tunisia)

 

Thank you sir.

TRF
Champion II
Champion II

OK.

Suppose I have a schema with a single column called idBeneficiaire  with the following values:

100
150
100
200
210
150
150
999

I can use the tAggregateRow like this:

- 1rst the output schema must have 1 column for the idBeneficiaire value + 1 column for the count result (datatype integer):

0683p000009LsLG.png

Then the tAggregate component can configured like this:

0683p000009Lsbp.png

The output column "idBeneficiaire" is populated from the same input column.

The output column "comptage" is the result of the count function applied on the column "idBeneficiaire".

When connected to a tLogRow the result looks like this:

Starting job test at 22:04 13/02/2018.

[statistics] connecting to socket on port 3474
[statistics] connected
.--------------+--------.
|      tLogRow_32       |
|=-------------+-------=|
|idBeneficiaire|comptage|
|=-------------+-------=|
|100           |2       |
|210           |1       |
|200           |1       |
|999           |1       |
|150           |3       |
'--------------+--------'

[statistics] disconnected
Job test ended at 22:04 13/02/2018. [exit code=0]

That's what you are looking for.

Anonymous
Not applicable
Author

Thank you sir, but it isn't what i search.

i must do a join between two tables (beneficiaire) and ( consultation)

beneficiaire : contains the informations about the beneficiaries and,

consultation: contains the informations about the consultations made.

The "idbeneficiaire" is unique . one id per one bénéficiaire.

So , to calculate for any beneficiaries how much consultation he's made per year, i must make the join between the both tables.

And the task, is the number of occurrence of "idbeneficiaire" in "consultation" table

Furthermore, based on tAggregateRow, i can apply functions only on data from a single source table.

The rest of the task, is the total number of consultation per beneficiary and per YEAR (how extract from Date). 0683p000009MACn.png

So, what do you think doing here ?

TRF
Champion II
Champion II

That's exactly what you get with tAggregateRow with the count function (number of consultations per beneficiaire).
However, if you need (want) to get some other informations from the consultation or the beneficiaire, you may have a join using a tMap and there you can count the number of consultations per beneficiaire using a sequence. For that, on the tMap output side, add a field called count or anything else (datatype Integer) and use the following to populate this field:
Numerique.sequence(row1.idBeneficiaire, 1)
This means you'll have a sequence for each unique idBeneficiaire which count the number of rows for the corresponding value.
So, 2 solutions for 1 question. That's where this tool is a great one.
Anonymous
Not applicable
Author

Hi TRF, 

i try your solution, but i find an error.

i try with " Numerique.sequence(mapping.idBeneficiaire, 1) " in tMap and with secondly a simple mapping.

in the picture you find the all of détails.

Thank you

 


aggregate.png
job.png
SEQUENCE.png
tmap.png
TRF
Champion II
Champion II

That's my mistake, change Numerique.sequence to Numeric.sequence.
I saw your design but don't understand why you still have tAggregateRow if you want to tMap with sequence.
Anonymous
Not applicable
Author

ok , I will try, stay here please