Focal Point
[CLOSED] Conditional Statement in a COMPUTE filed in Report and the BY FIELD

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/1717017096

August 24, 2018, 09:29 AM
srajeevan
[CLOSED] Conditional Statement in a COMPUTE filed in Report and the BY FIELD
Hi ,

I have a question.
I want to make sure ,whether the approach i am trying is correct or not.

I have a requirement where i have to calculate the counts of some event in the same category.
But event1 count logic is different than event2 count logic.

I created a HOLD file where i captured counts of events with no where clause.
Then used that HOLD file to filter for event1 and stored in a COMPUTE field. -- step 1 ---stored in a HOLD.
Used the same HOLD file to filter for event2 and stored in a COMPUTE field.--- step1 -- stored in a HOLD.
Then appended together using MORE command.

Can i do this in one go using an IF ELSE condition in step 1.

Also if i use IF ELSE ,
To which BY FIELD the calculation of IF ELSE is done?

This message has been edited. Last edited by: FP Mod Chuck,


WF8206,Windows 7,8,10
HTM,PDF,EXCEL
August 24, 2018, 10:57 AM
MartinY
You can sometime do the following way, but without your requirement, difficult to say if it's a good option or not.
But since it does work the way you did it you can stay with that option. Doing in one step doesn't mean that it will be faster or better.

DEFINE FILE abc
event1 /P6 = IF cond EQ 'myFirstCond'  THEN 1 ELSE 0;
event2 /P6 = IF cond EQ 'mySecondCond' THEN 1 ELSE 0;
END
TABLE FILE abc
SUM event1
    event2
BY x
END



WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
August 24, 2018, 12:06 PM
srajeevan
I have different BY field conditions for calculating count(evene1) and count(event2)
For Ex : for calculating count(event1)
I have
 
BY LOWEST 1 COLUMN1
BY LOWEST 1 COULMN2
 


For count(event2) , i don't have to stick to that business rule.

So If i use IF ELSE ,how can i calculate for the BY FIELD conditions.
I am confused?

For which BY FILED the IF ELSE calculate to?I came across from someone that IF ELSE caculate to the LOWEST BY FIELD or FIRST BY FIELD.Any such thing?


WF8206,Windows 7,8,10
HTM,PDF,EXCEL
August 24, 2018, 01:46 PM
MartinY
You may want to look at the following
TABLE FILE CAR
SUM CNT.MODEL AS 'NB_MODEL PER COUNTRY'
BY COUNTRY
SUM CNT.MODEL AS 'NB_MODEL PER CAR'
BY COUNTRY
BY CAR
END

But like I already stated, since it seems to be complicated, you may want to stay with your actual working option.
As we say : do not change a winning situation if it's not giving nothing more.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007