Focal Point
[CLOSED] SUM FIELD OMITTING VALUE

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

February 19, 2019, 04:14 PM
Trentj
[CLOSED] SUM FIELD OMITTING VALUE
I have a define field that is created by the following:
IF "C&C Code" EQ 'VDIG01' THEN 'Digital Homes' ELSE IF "C&C Code" IN ( 'VPEXS' , 'VBEXS' , 'VNEXS' , 'VPBAS' , 'VBBAS' , 'VNBAS' , 'VDIG01' ) THEN 'Basic Subs' ELSE IF "C&C Code" EQ 'VPEXM' OR 'VBEXM' OR 'VNEXM' OR 'VPBAM' OR 'VBBAM' OR 'VNBAM' OR 'VPDIM' OR 'VNDIM' OR 'VBDIM' THEN 'EBU Room Count' ELSE IF "C&C Code" EQ 'VPDIS' OR 'VBDIS' OR 'VNDIS' OR 'VPDMX' OR 'VBDMX' OR 'VNDMX' THEN 'Digital Programming' ELSE IF "C&C Code" EQ 'VQD00' OR 'VQS00' OR 'VQMA0' OR 'VQSL0' OR 'VQTMI' OR 'VQTT6' OR 'VQTQU' THEN 'Set Top Boxes' ELSE 'UNKNOWN CATEGORY'

I then have another define field that gets a quantity using this:
IF "Period" EQ d_prd AND "C&C Code" EQ 'SWDS1' THEN "Quantity" * 5 ELSE IF "Period" EQ d_prd AND "C&C Code" NE 'SWDS1' THEN "Quantity" ELSE 0

The issue is that when I use that define field and do a SUM, it not including the amounts from the Digital Homes category in the Basic Subs category. Both categories are created just fine, but the SUM isn't happening like I think it should. What have I done wrong?

This message has been edited. Last edited by: FP Mod Chuck,
February 19, 2019, 04:23 PM
BabakNYC
So, your field is Digital Homes if and only if C&C Code is VDIG01 but it's Basic Subs when it's one the 7 values you list (including VDIG01) which are essentially OR'd.

You have an overlap of values.


WebFOCUS 8206, Unix, Windows
February 19, 2019, 04:44 PM
Trentj
Correct, I knwo they overlap, I am trying to duplicate the results of an excel spreadsheet, however that is proving tough to replicate all the data manipulation that is possible in Excel here on this platform.
I was basically reaching out to see if I was missing anything or if anyone knew how to get around it.

This message has been edited. Last edited by: Trentj,
February 19, 2019, 06:57 PM
Addy
Hi,
Do you want to create one column or multiple columns?
Why I ask is because you want to count a field in both the catagories which is part of the same column.. that is a bit confusing. In your excel sheet is are all these Catagories different columns or rows of the same column?
Any tool including excel will never evaluate Else part if the "IF" part is true..

that's the nature of IF ELSE statement..


WF 8.2.04
Windows/Unix
All Formats
In Focus since 2006
February 19, 2019, 07:41 PM
Trentj
It creates both categories I am assuming due to the other codes in the basic subs. The Sum just omits it from the one category. That's why I am confused, the sum is what is omitting not the category. The sum has nothing in it besides looking for the one specific condition and in both basic subs and digital homes categories it falls within the ELSE condition, not the IF Also, it isn't a condition in Excel that is combining the two it's adding specific columns.

This message has been edited. Last edited by: Trentj,
February 20, 2019, 03:28 AM
Addy
As I said earlier IF ELSE will check the conditions sequentially.
If the condition is true for one statement it will not go and check the condition in the next statement irrespective if that is an IF or Else IF statement.
You need to understand that if the condition is met for Digital Homes it will not go and evaluate the condition for Basic Subs.
My assumption is with the help of the above statement you are either creating a Define or a Compute field.
Even if you will use PRINT it will give you the same results as it can only assign one value to the field based on the condition.


WF 8.2.04
Windows/Unix
All Formats
In Focus since 2006
February 20, 2019, 07:28 AM
MartinY
quote:

Originally posted by Trentj:

I am trying to duplicate the results of an excel spreadsheet

I think that based on previous different answer and above sentence you should ask yourself this :

What is the data source ?
Is there any manipulation done on data prior to produce that Excel result ?

On the second one, it seems that the answer is yes. As per stated previously, you cannot have tow conditions meet within the same IF statement so, data has probably been manipulated.


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
February 20, 2019, 10:39 AM
Trentj
Thank you to all. I understand why it isn't happening now (the digital homes category is for the VDIG01 only so when the SUM of my other define field is evaluated for that category, it is only counting the quantity for that code. Where the Basic Subs category, has all the other codes EXCEPT the VDIG01 cause it was evaluated in the DIGITAL HOMES category so the SUM for the second define field omits that field cause it doesn't exist in the first define field definition.)
Sorry if this question drove everyone nuts, I just mainly wanted to make sure I wasnt missing anything. I have another format of the report where I have define fields for each of the categories, then I can sum the basic sub category and digital homes define fields to get a total field and that works. I just can't get the difference between the two period results to show below in an excel like fashion. thanks to all that replied and again I apologize if it seemed like such a noob question.
February 20, 2019, 11:05 AM
FP Mod Chuck
Trentj

Welcome to Focal Point! No need to apologize that is what this forum is all about!

When a thread is done you can go back and edit your first post and change the summary to have the word [SOLVED} or [CLOSED] at the beginning so everyone knows there is some kind of resolution.


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats