Skip to main content
Question

Result unexpected by Static Calculator

  • February 14, 2020
  • 11 replies
  • 42 views

gogopotter90
Contributor
Forum|alt.badge.img+14

Result unexpected by Static Calculator

Ā 

i have A B C Columns,each column has different years so i want to count how many year duplicate or not in each column and sum the count attribute at the end

so i should do count and sum for each column A B C and get table as result for 3 column in one table beside eachother .

so what i did exactly i used 3 static calculator and each one i defined count and analyze to attribute and output of first a input for second and output of second as input for third but i found the result is incorrect but if i used two static calculator ,the result is erfect but only for 2 columns but i want to do for 3 column .

then i used aggregator to sum the count

Does we have a way to use one static calculator and do sum for 3 columns and count once a time

Ā 

i want to count each the first 3 columns for year and get the sum of each count but i do not want to count empty cell if exist.Thanks

.Thanks

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

11 replies

takashi
Celebrity
  • February 15, 2020

Could you please post some screenshots that illustrate the worlflow on the canvas and how you did configure each StatisticsCalcuoator parameters? It would be ideal if you could post your workspace and the source dataset, of course.


bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • February 15, 2020

WhenĀ IĀ getĀ toĀ needingĀ multipleĀ statisticsĀ and/orĀ multipleĀ fieldsĀ thenĀ usuallyĀ IĀ sendĀ thisĀ offĀ toĀ InlineQuerierĀ instead.

SendĀ yourĀ tableĀ intoĀ InlineQuerierĀ asĀ sayĀ "DataTable"

ThenĀ getĀ InlineQuerierĀ toĀ returnĀ 3Ā statisticalĀ tables:

  • YearACount
  • YearBCount
  • YearCCountĀ 

UsingĀ theĀ followingĀ 3Ā separateĀ SQLĀ statementsĀ toĀ getĀ theĀ StatisticsĀ forĀ eachĀ FieldĀ inĀ 3Ā differentĀ OutputĀ PortsĀ fromĀ InlineQuerier

SELECTĀ AttributeA,Ā Count(*)Ā ASĀ CountAttributeAĀ FROMĀ DataTableĀ GROUPĀ BYĀ AttributeA
SELECTĀ AttributeB,Ā Count(*)Ā ASĀ CountAttributeBĀ FROMĀ DataTableĀ GROUPĀ BYĀ AttributeB
SELECTĀ AttributeC,Ā Count(*)Ā ASĀ CountAttributeCĀ FROMĀ DataTableĀ GROUPĀ BYĀ AttributeC

AnĀ alternativeĀ isĀ toĀ putĀ themĀ allĀ inĀ oneĀ statisticalĀ lookupĀ table,Ā withĀ aĀ singleĀ SQLĀ resultĀ calledĀ "YearCounts".Ā Ā ToĀ useĀ themĀ downstreamĀ isĀ toĀ separateĀ themĀ backĀ outĀ withĀ somethingĀ likeĀ anĀ AttributeFilterĀ toĀ "AttributeName".Ā Ā TheĀ singleĀ SQLĀ statementĀ isĀ isĀ likeĀ this:

SELECTĀ AttributeA,Ā Count(*)Ā ASĀ YearCount,Ā "AttributeA"Ā ASĀ AttributeNameĀ FROMĀ DataTableĀ GROUPĀ BYĀ AttributeA
UNIONĀ ALLĀ SELECTĀ AttributeB,Ā Count(*),Ā "AttributeB"Ā FROMĀ DataTableĀ GROUPĀ BYĀ AttributeB
UNIONĀ ALLĀ SELECTĀ AttributeC,Ā Count(*),Ā "AttributeC"Ā FROMĀ DataTableĀ GROUPĀ BYĀ AttributeC

gogopotter90
Contributor
Forum|alt.badge.img+14
  • Author
  • Contributor
  • February 15, 2020

WhenĀ IĀ getĀ toĀ needingĀ multipleĀ statisticsĀ and/orĀ multipleĀ fieldsĀ thenĀ usuallyĀ IĀ sendĀ thisĀ offĀ toĀ InlineQuerierĀ instead.

SendĀ yourĀ tableĀ intoĀ InlineQuerierĀ asĀ sayĀ "DataTable"

ThenĀ getĀ InlineQuerierĀ toĀ returnĀ 3Ā statisticalĀ tables:

  • YearACount
  • YearBCount
  • YearCCountĀ 

UsingĀ theĀ followingĀ 3Ā separateĀ SQLĀ statementsĀ toĀ getĀ theĀ StatisticsĀ forĀ eachĀ FieldĀ inĀ 3Ā differentĀ OutputĀ PortsĀ fromĀ InlineQuerier

SELECTĀ AttributeA,Ā Count(*)Ā ASĀ CountAttributeAĀ FROMĀ DataTableĀ GROUPĀ BYĀ AttributeA
SELECTĀ AttributeB,Ā Count(*)Ā ASĀ CountAttributeBĀ FROMĀ DataTableĀ GROUPĀ BYĀ AttributeB
SELECTĀ AttributeC,Ā Count(*)Ā ASĀ CountAttributeCĀ FROMĀ DataTableĀ GROUPĀ BYĀ AttributeC

AnĀ alternativeĀ isĀ toĀ putĀ themĀ allĀ inĀ oneĀ statisticalĀ lookupĀ table,Ā withĀ aĀ singleĀ SQLĀ resultĀ calledĀ "YearCounts".Ā Ā ToĀ useĀ themĀ downstreamĀ isĀ toĀ separateĀ themĀ backĀ outĀ withĀ somethingĀ likeĀ anĀ AttributeFilterĀ toĀ "AttributeName".Ā Ā TheĀ singleĀ SQLĀ statementĀ isĀ isĀ likeĀ this:

SELECTĀ AttributeA,Ā Count(*)Ā ASĀ YearCount,Ā "AttributeA"Ā ASĀ AttributeNameĀ FROMĀ DataTableĀ GROUPĀ BYĀ AttributeA
UNIONĀ ALLĀ SELECTĀ AttributeB,Ā Count(*),Ā "AttributeB"Ā FROMĀ DataTableĀ GROUPĀ BYĀ AttributeB
UNIONĀ ALLĀ SELECTĀ AttributeC,Ā Count(*),Ā "AttributeC"Ā FROMĀ DataTableĀ GROUPĀ BYĀ AttributeC

itĀ looksĀ likeĀ easyĀ butĀ iĀ triedĀ bothĀ ofĀ methodĀ butĀ iĀ gotĀ noĀ outputĀ onĀ inspectorĀ andĀ alsoĀ iĀ needĀ toĀ sumĀ theĀ Ā resultĀ ofĀ countĀ ,couldĀ youĀ provideĀ meĀ withĀ exampleĀ orĀ explainĀ inĀ screenĀ shotsĀ soĀ iĀ canĀ doĀ itĀ inĀ correctĀ wayĀ thanksĀ alot

Ā 

Ā 


gogopotter90
Contributor
Forum|alt.badge.img+14
  • Author
  • Contributor
  • February 15, 2020

Could you please post some screenshots that illustrate the worlflow on the canvas and how you did configure each StatisticsCalcuoator parameters? It would be ideal if you could post your workspace and the source dataset, of course.

Ā 

i got output that counted year as i want for 3 columns but i want to get sum also so i used aggregator but it gives me output only for one column counted but sum of 2 columns are missed.

year.xlsx

i want to count each the first 3 columns for year and get the sum of each count but i do not want to count empty cell if exist.

the result will be in new table all attributes beside each other.Thanks

Ā 

FME version 2018


takashi
Celebrity
  • February 15, 2020

Thanks for sharing the sample dataset. Is this your desired result?


gogopotter90
Contributor
Forum|alt.badge.img+14
  • Author
  • Contributor
  • February 15, 2020

Thanks for sharing the sample dataset. Is this your desired result?

it should looks like it but i want also to put construction column and bridge column beside these attributes(teh rest of the table) then i want to get the sum of each count under it ,under the first column result word then under count_A 7 , under Count_B 6,under the count_C 3 ,i want to ask ,is it possible to count number 0 beside missing attribute in each count or we should only remove mising by tester iam asking about 0 bcs i i modified it manuel in the future so i want the sum change later and i need still empty celll .thanks for help

have coomon id so i do not want 1985 to count as 2 bcss each row has his own id as picture


takashi
Celebrity
  • February 15, 2020

Sorry, it's hard to understand what table you are attempting to create. Can you show us your desired table which should be created based on the sample data?


gogopotter90
Contributor
Forum|alt.badge.img+14
  • Author
  • Contributor
  • February 15, 2020

Sorry, it's hard to understand what table you are attempting to create. Can you show us your desired table which should be created based on the sample data?

i did aggregator and it works good but i have small problem ,how can i count missing value as 0 because it counts it as one .and also when i write in aggregator attribute to sum count a ,count b,count c .it gives me no result for sum . could u give me suggestion how can i write sum for three column once a time and thanks

Ā 

input.xlsx

result_year.xlsx


takashi
Celebrity
  • February 15, 2020

Thanks for sharing the sample dataset. Is this your desired result?

In your sample data, there isn't "id" attribute. Where the "id" come from?

Should count_X always be 1 if year_X has a value regardless whether there are duplicate years? (X = A, B, or C)


takashi
Celebrity
  • February 15, 2020

I think this workflow would create a table close to your requirement. You can set count_X with conditional value setting - i.e. 1 if year_X has a value, 0 otherwise.

See also this workspace example: count-years.fmwt (FME 2019.2.3)


gogopotter90
Contributor
Forum|alt.badge.img+14
  • Author
  • Contributor
  • February 15, 2020

I think this workflow would create a table close to your requirement. You can set count_X with conditional value setting - i.e. 1 if year_X has a value, 0 otherwise.

See also this workspace example: count-years.fmwt (FME 2019.2.3)

It works so supe,thanks alot