Search code examples
crystal-reportscrystal-reports-2008

Crystal Formula to display the latest


A table has workout columns starting from workout1 till workout7.

I want to create formula to check the latest workout (higher) and display it in crystal report. For example, check if workout7 have value then display it before any other workout columns else check workout6, If it value, display it before other columns and so on.

But I think if-else statement is not the right choice to perform this job. What is the right way to do that?

Any help would be appreciated,

Table


Solution

  • The value needs to be checked if is not null, and then if the value is not null, print it, else continue checking the steps in descending approach, and whenever the value is found just print it.

    if NOT ISNULL ({EB_Tam_DailyMv.dmv_workout10}) then
    {EB_Tam_DailyMv.dmv_workout10}
    
    else  if NOT  ISNULL ({EB_Tam_DailyMv.dmv_workout9}) then
    {EB_Tam_DailyMv.dmv_workout9}
    
    else if  NOT ISNULL ({EB_Tam_DailyMv.dmv_workout8}) then 
    {EB_Tam_DailyMv.dmv_workout8}
    
    else if  NOT ISNULL ({EB_Tam_DailyMv.dmv_workout7}) then 
    {EB_Tam_DailyMv.dmv_workout7} 
    
    else if NOT ISNULL({EB_Tam_DailyMv.dmv_workout6}) then 
    {EB_Tam_DailyMv.dmv_workout6}
    
    else if NOT ISNULL({EB_Tam_DailyMv.dmv_workout5}) then 
    {EB_Tam_DailyMv.dmv_workout5}
    
     else if NOT ISNULL({EB_Tam_DailyMv.dmv_workout4}) then 
     {EB_Tam_DailyMv.dmv_workout4}
    
     else if NOT ISNULL ({EB_Tam_DailyMv.dmv_workout3}) then 
     {EB_Tam_DailyMv.dmv_workout3}
    
    else if NOT ISNULL ({EB_Tam_DailyMv.dmv_workout2}) then 
    {EB_Tam_DailyMv.dmv_workout2}
    
    else if NOT ISNULL ({EB_Tam_DailyMv.dmv_workout1}) then 
    {EB_Tam_DailyMv.dmv_workout1}
    
    else "00:00"