Replacing column with other column when Data is blank in Crystal report


I want to replace the Column A with the adjacent Column B if column A data is NULL (dynamically shifting).

For more reference kindly find the attached image
Sailee GovekarStudentAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pawan KumarDatabase ExpertCommented:
Please use like below -

You have to write a crystal report formula-

if isnull({col1}) then {col2} 

Open in new window

Pawan KumarDatabase ExpertCommented:
Edited my last comment.
Raghavendra HullurSoftware DeveloperCommented:
From the image, it seems you want to suppress the field Weight itself when the value is blank and shift other 5 fields to left is it?
If so, you need to set the x position dynamically.

Correct me if I am wrong.
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

Sailee GovekarStudentAuthor Commented:

I want to shift the columns to the left when the Weight column is blank or null.

If the weight column is not null then it will display normally. without any column shifting.
Raghavendra HullurSoftware DeveloperCommented:
I think you need to play with the position size and set the value.
You can try for one field and then set the value for other 4 fields accordingly.
For the field with value "Washing", you can try setting X position (Right click field --> Size and Position --> click X+2 against X).
The value of positions is in pixels I think, normally we check for a value of 1440 per inch movement. For e.g. if I want to move a field 2 inches to right then, 1440*2 something like that, but in your case, it may vary as the fields may not be always a inch apart.
You can try including below formula and adjust the value accordingly after previewing it.

Formula for X+2 for X position of your field with value Washing:

if isNull({your field which may have blank value}) then -1440 else 1

Include this and check how much the field has moved and adjust if you want to have more shift. You can use any value not just 1440.

Hope this helps.
Sailee GovekarStudentAuthor Commented:
I have one boolean field for viewing or suppressing weight column namely, IsWeightVisible

will it be useful?
Raghavendra HullurSoftware DeveloperCommented:
Not sure what is that used for.
Is it the one which give blank data or some data for Weight column? If yes, then you can use that instead of the field to check for blank.
If not, you need to use the field which gives the output for Weight column.
Raghavendra HullurSoftware DeveloperCommented:
Basically, we try to check whether the value for your Weight column is blank or not.
Sailee GovekarStudentAuthor Commented:
Yes, IsWeightVisible provides the condition whether the weight is available or not.
Sailee GovekarStudentAuthor Commented:
So if I create same fields like washing, drying, etc and set the suppressing property to True or False then it will work!

I suppose.
Raghavendra HullurSoftware DeveloperCommented:
You are not setting any suppressing, you will be writing X position shift formula for each of those  5 fields.
Raghavendra HullurSoftware DeveloperCommented:
Seems it's confusing for you? Share the report with some sample data. Unless there are additional calculations, it shouldn't take much time.
Sailee GovekarStudentAuthor Commented:
Kindly find the report on this path:

Report Name : Report2

Secondly, I have implemented the suppressing format, because the formula you explained I didn't understood
Raghavendra HullurSoftware DeveloperCommented:
I don't see the information you shared via screenshot in the report you attached. Is it the one you are working or is there any suppression? Can you share with same sample data or further details of section in which those details used?
Sailee GovekarStudentAuthor Commented:
Raghavendra HullurSoftware DeveloperCommented:
This is what I see when I open your report.
Can you tell me which field will have blank data?
Mike McCrackenSenior ConsultantCommented:
Are the other 5 columns the same data types as the weight field?

If so you could do it with formulas

If IsWeightVisible  then
   {Weight Field}
   {Washing field}

Similarly for the other 4 columns.

Suppress the last column with the IsWeightVisible  parameter

Sailee GovekarStudentAuthor Commented:
If you view the report, under field washing there is a field Weight
Raghavendra HullurSoftware DeveloperCommented:
I am still trying to figure out the Weight you said under Washing.

As per your original requirement, it's suppose to be on left of Washing, Drying etc..

But now you are saying Weight is under Washing, but that isn't visible at all.

All I see is a OLE object then a text object with message "Do not wash - non lavare", then another OLE object followed by the same message displayed earlier.
Sailee GovekarStudentAuthor Commented:
I have deleted the the fields for your understanding.
Raghavendra HullurSoftware DeveloperCommented:
Can you explain with reference to the latest report you shared on what field you want to move. it would be better you have screenshot of latest report with instructions on what fields to be moved without changing anything further. You are changing the content again and again which is not helping to resolve the issue.
Mike McCrackenSenior ConsultantCommented:
I think you have it working with weight suppressed and washing moved over.  Just do the same thing for the other objects.  Create a copy and put it one column left.  Same for the big header make a copy and move it left.  Use the same suppression.  

Raghavendra HullurSoftware DeveloperCommented:
Oh, I didn't think of that. Yes, I could see those 2 fields overlapped from the Report Explorer. But I can also see that there is no dynamic position is applied on the Washing field. Position formula needs to be changed for the same.
Mike McCrackenSenior ConsultantCommented:
Don't need dynamic positioning if you put multiple copies of the field on the report.  Just suppress the one(s) you don't want to see.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Raghavendra HullurSoftware DeveloperCommented:
Yes, that is also a better idea. I hope @Sailee knows about this. Else, we could help her.
Mike McCrackenSenior ConsultantCommented:
She is using it on the weight and wash fields.  Just a matter of extending to all fields.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.