Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Order of appearance formula Post Reply Post New Topic
<< Prev Page  of 2
Author Message
Andrewarbogast
Newbie
Newbie
Avatar

Joined: 21 Aug 2017
Location: United States
Online Status: Offline
Posts: 39
Quote Andrewarbogast Replybullet Posted: 07 Sep 2017 at 7:12am
Ok...haha sorry for all the posts. I have tested each of these 5 statements individually and they work. The question is how do I join them together?

//if isnull({tbl_DA_Mental_Health.Data_Entry_Date})then
//    {tbl_DA_Adult_Mental_HA.Data_Entry_Date}
//else {tbl_DA_Mental_Health.Data_Entry_Date}
//

//if isnull({tbl_DA_Adult_Mental_HA.Data_Entry_Date})then
//    {tbl_adult_intake_assess_V2.Data_Entry_Date}
//else {tbl_DA_Adult_Mental_HA.Data_Entry_Date}

//if isnull({tbl_adult_intake_assess_V2.Data_Entry_Date})then
//    {tbl_adult_intake_assessment.assessment_date}
//else {tbl_adult_intake_assess_V2.Data_Entry_Date}

//if isnull({tbl_adult_intake_assessment.assessment_date})then
//    {tbl_v2_adult_intake.assessment_date}
//else {tbl_adult_intake_assessment.assessment_date}

if isnull({tbl_v2_adult_intake.assessment_date})then "MHA Missing"
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Sep 2017 at 7:58am
You can't really stitch them together that way.
I assume there is a hierarchy to the 5 fields, meaning that if field 1 is not empty it is the value to use, then if field 2 is not empty it is the value to use, etc.
Is this a correct assertion? If so, what is that hierarchical sequence?
IP IP Logged
Andrewarbogast
Newbie
Newbie
Avatar

Joined: 21 Aug 2017
Location: United States
Online Status: Offline
Posts: 39
Quote Andrewarbogast Replybullet Posted: 07 Sep 2017 at 8:05am
Yes you are correct. the hierarchy is:
{tbl_v2_adult_intake.assessment_date}
{tbl_adult_intake_assessment.assessment_date}
{tbl_adult_intake_assess_V2.Data_Entry_Date}
{tbl_DA_Adult_Mental_HA.Data_Entry_Date}
{tbl_DA_Mental_Health.Data_Entry_Date}

I also tried this formula and it works for the first three fields but not sure how to add in the last two.


if isnull({tbl_v2_adult_intake.assessment_date})
then
(
if isnull({tbl_adult_intake_assessment.assessment_date})
then
    {tbl_adult_intake_assess_V2.Data_Entry_Date}
else
    {tbl_adult_intake_assessment.assessment_date}
)
else
{tbl_v2_adult_intake.assessment_date};
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Sep 2017 at 8:23am
if not isnull({tbl_v2_adult_intake.assessment_date} ) then totext({tbl_v2_adult_intake.assessment_date})
else if not isnull({tbl_adult_intake_assessment.assessment_date}) then totext({tbl_adult_intake_assessment.assessment_date})
else if not isnull({tbl_adult_intake_assess_V2.Data_Entry_Date}) then totext({tbl_adult_intake_assess_V2.Data_Entry_Date})
else if not isnull({tbl_DA_Adult_Mental_HA.Data_Entry_Date}) then totext({tbl_DA_Adult_Mental_HA.Data_Entry_Date})
else if not isnull({tbl_DA_Mental_Health.Data_Entry_Date}) then totext({tbl_DA_Mental_Health.Data_Entry_Date}) else "MHA Missing"
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 07 Sep 2017 at 8:23am
Back to the error message.  You were checking the fields against a "", so I made the assumption the fields were strings. The issue you are going to have is the formula has to return a single data type.  It will not return a date or a string (last if statement).  My formula would work if you replaced the = '' with the isnull check (as you did in the previous post), but also for the last if statement to work where you have the phrase "MHA Missing", the result of each if statement will have to be converted to a string (i.e, CSTR or TOTEXT).
IP IP Logged
Andrewarbogast
Newbie
Newbie
Avatar

Joined: 21 Aug 2017
Location: United States
Online Status: Offline
Posts: 39
Quote Andrewarbogast Replybullet Posted: 07 Sep 2017 at 8:42am
Thanks!!! The formula worked great.
IP IP Logged
<< Prev Page  of 2
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.