| Author |
Message |
jeffnehman
Newbie
Joined: 25 Jan 2012
Location: United States
Online Status: Offline
Posts: 7
|

Topic: How do I set a conditional field display in XI? Posted: 25 Jan 2012 at 12:20pm |
|
The table with my data contains a (manufacturer's) code. I want to display the name--which I am obtaining from another table. I am doing an outer join because there isn't a 1 for 1 matching. There are some instances where the code doesn't correspond with a name--but it does correspond with another field in the table that has the name.
Currently, my report is displaying a line with the name and the appropriate dollar amounts in each column. There are 2 examples where the manufacturer's name isn't found or displayed. In those cases, the name on the line is blank.
What I want to do is create a condition to bypass the blank name. Something to the effect of: if {pmf_display} is null then .....
The tables are outer joined on the code (pmf_id) but the code in the main table can be joined to a different field (pmf_acct) in the name table. So, I also tried: if {pmf_acct} = 'AGG' then 'Agg' else if {pmf_acct}='CRN' then 'Crn' else {pmf_display}
No matter what I do, I get BOOLEAN errors. I'm sure it is a simple fix (I can easily do it in any SQL editor). I just need to figure out how to do it in Crystal Xi.
|
IP Logged |
|
|
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 26 Jan 2012 at 3:44am |
sounds like you are putting the formula in the select expert. That is only used to determine what rows to include or exclude fromther report (boolean reult of your formula)
try instead creating a formula field in the field explorer.
|
IP Logged |
|
jeffnehman
Newbie
Joined: 25 Jan 2012
Location: United States
Online Status: Offline
Posts: 7
|

Posted: 26 Jan 2012 at 4:38am |
|
Thank you. That seems to get me halfway there. I can control the display there but I (somehow) need to edit the join to control the display. I realize that isn't very clear.
In simplified terms, we are tying to display the sales volume by manufacturer. The general ledger ("GL") contains a manuf. code (pmf_id) which I am joining to the manufacturer table. But, in some cases, the code in the GL doesn't match the code in the manuf. table. That is because some manuf. codes are grouped into categories. So, when the manuf. code (pmf_id) in the GL doesn't have a corresponding pmf_id in the manuf. table, I use the pmf_acct field (the group) in the manfu. table.
In SQL, in the SELECT section, I can use the CASE functionality to display pmf_id when it exists (isn't null) OR ELSE use the pmf_acct code (or even further clarified, such as CASE WHEN ISNULL(pmf_id) THEN WHEN pmf_acct='AGG' THEN 'Aggregate' ELSE WHEN pmf_acct='CRN' THEN 'Crane' ELSE pmf_display END END). I don't know how to do that in Crystal.
When I create the formula field, I am using "if isnull({pmf.pmf_acct}) then {pmf.pmf_acct} else {pmf.pmf_display}" but that doesn't change anything. If I change the statement to remove "{pmf.pmf_acct}" and replace it with something like "AGG" then "AGG" appears for all blanks (not just the ones that it should.d So, I know the ISNULL part is correct. I think the problem goes back to my join statement.
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 26 Jan 2012 at 4:53am |
I thnk you just need to invert your if-then statement
if isnull({pmf.pmf_acct}) then {pmf.pmf_display} else {pmf.pmf_acct}
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 26 Jan 2012 at 4:58am |
I can't totally "see" your set up but when doing outer joins make sre you do not have a select stement incrystal that invlaidates the outer join.
also usually the isnull() part of the statement references the table that has the fewer records
|
IP Logged |
|
jeffnehman
Newbie
Joined: 25 Jan 2012
Location: United States
Online Status: Offline
Posts: 7
|

Posted: 26 Jan 2012 at 5:21am |
|
Thanks again. I was trying to be detailed but not too detailed to make it confusing. In my manuf. table, the group (pmf_acct) and the manuf. code (pmf_id) both always exist but only the pmf_acct always matches the record in the GL table. Think of it this way: the pmf_id could be CHEVY, GMC, PONTIAC, CADILLAC, BUICK, etc and each will have a group (pmf_acct) of GM (the group or parent company). In other cases, Hyundai would be both the group (pmf_acct) and the code (pmf_id). The difference would be whether or not we roll the code up to another group or if we keep the group the same as the code.
The group is what appears in our GL. In many cases the group is the same as the code, but there are some instances (see the above example) where that isn't the case.
What this means is that my join can't or shouldn't be the code from GL to the group from the manuf. table since the GL code (GM) would have at least 5 matches in the manuf. table. By trying to match the GL code of GM to the code in the manuf. table, no match is found. With the outer join, I get a blank record. That is why I want to put a condition on the display to display the manuf's full name when the code is found and the group when it isn't.
Hopefully, I am clarifying and not confusing. Thanks again.
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 26 Jan 2012 at 6:00am |
so you have a NULL match in the gl join field, correct?
Maybe this one?
if isnull(gl.field) then {pmf.pmf_display} else {pmf.pmf_acct}
|
IP Logged |
|
jeffnehman
Newbie
Joined: 25 Jan 2012
Location: United States
Online Status: Offline
Posts: 7
|

Posted: 26 Jan 2012 at 6:12am |
|
Close but gl.field (assuming that gl.field is my code (pmf_id)) is never null.
This is what I currently have and what I meant to write before(but there was a typo).
if isnull({pmf.pmf_display}) then {pmf.pmf_acct} else {pmf.pmf_display}
But, that doesn't change the display. I still get the blanks for the original 2 examples. If I do what you wrote, it doesn't fix the problem (probably because pmf_id isn't ever null.
|
IP Logged |
|
jeffnehman
Newbie
Joined: 25 Jan 2012
Location: United States
Online Status: Offline
Posts: 7
|

Posted: 26 Jan 2012 at 6:21am |
|
Again, adding the formula field (and replacing the display with the formula field) of if isnull({pmf.pmf_display}) then {pmf.pmf_acct} else {pmf.pmf_display}
doesn't change anything from before adding the formula field. BUT, if I replace "pmf.pmf_acct" with (say) "ABC", then my 2 blank lines show "ABC". So, I am partially there. I just need the pmf.pmf_acct part to work. Again, I think the issue is the join. The line is blank when it didn't find a join. Therefore, there is no pmf_acct to put there (likely the reason the field is blank). I may be able to hard code it by saying if pmf_display is null then IF pmf_id='AGG' then 'Aggr' else if pmf_id='CRN', then 'Crane' else pmf_display.
That should work. Then, if there are any other codes (pmf_id's) that don't correspond, I will get blanks for those and then can edit the code when they occur.
|
IP Logged |
|
jeffnehman
Newbie
Joined: 25 Jan 2012
Location: United States
Online Status: Offline
Posts: 7
|

Posted: 26 Jan 2012 at 6:30am |
|
It did work. I greatly appreciate your help and patience! Without it, I wouldn't have made it this far.
Jeff
|
IP Logged |
|
|
|