Create an "Is Blank" / "Not Blank" Binding Converter

This binding converter would allow something to be true/false, if the source contains ANY info or not. This would be very helpful for certain things to happen if an Excel cell is blank. Or if the cell contains something.

Here’s a simple example that I run into ALOT:
Often when working with a data set in Excel, there will be some columns that contain information in the row, and some that do not. For example, if I’m going to show a list of something I might have ListHeader, ListItem1, ListItem2, ListItem3. But not all the records may have 3 items in the list. Some may have two, and some might have 1.

I only want bullet points to show up next to items in the list that are NOT blank. So I could bind the visibility of the bullet point to the list item, and set the converter to be “Not Blank” So that means visibility is TRUE when the current excel cell is Not Blank…ie; contains anything.

I know this can be done by adding a column for EVERY list item called Show bullet with True/False. But that gets redundant to have a column for every list item. Also, it doesn’t account for dynamic data…which means you’d need to manually label true/false for each row yourself.

My example is simple, but there are many more uses…and more complex things can be done. For example, setting Toggle buttons to check/uncheck based on data that is or isn’t there - opening up your whole list of actions.

This binding converter would be another step forward to dynamic elements that are conditional to the data being shown.

  • Agree
  • Disagree

0 voters

Hey @AlexB

We come across that a lot. We bind the visibility with a custom converter.

if(INPUT==“null”)
False;
else
True;

You can use equate it to Blank ("") or any other value you like.

Hope this helps.

1 Like

Sweet, thanks @AlexL !
One of these days I need to get more familiar with some of these custom functions. This helps a lot.

Hey @AlexL, I actually just tried this and couldn’t get it to work. I went to the Javascript library page that the documentation refers to and tried a bunch of other things (changing the “” to null, undefined, (), etc. But I’m like a blind man navigating a maze here lol.

Could it be that the excel sheet I’m comparing to doesn’t have numerical values, it’s just a bunch of text statements?

Maybe I missed something? Thanks again for any advice.

Hey @AlexB,

I just tried this on an empty cell…

if(INPUT=="")
false;
else
INPUT;

on a text asset I got the actual value or the word “false”.

I changed INPUT to true and put it in the visibility property and it worked as expected.

So, the question to you, what type of field (cell) is it? is it a string, an integer? is it holding a blank or an actual NULL value?

Can you look at the IFD file and see what type it is? if it’s a number, try equals 0.

If you are still having issues with this, can you send me the Excel IA folder with sample data I can look at here.

Let me know.

1 Like

@AlexL You’re a life saver, thanks so much for your help once again. I FIGURED IT OUT!

It’s actually a small thing that needs to change in your script. True/False need to be “True” and “False”. That must be the way the visibility boolean needs to see the value.

Once I added quotes, my bullet points magically appear and disappear according to blank/non-blank cells! Hooray!

This small piece of information may also be a huge help for a different project too. Very grateful.

P.s. I can also verify this works when you bind visibility to the excel sheet cell, or directly to the text item.

(I edited this statement) At first, I thought this was only working part of the time. But now I see that when you bind the visibility to a text item that is bound to excel…in composer, it may not always be accurate if you edit the excel doc on the fly.

But when running the program, it appears to work as normal. Just a small tip I learned.

@AlexB

Check for extra spaces inside any quotes…make sure the semicolons (:wink: are in the right places…

I use it all the time and can attest to it working…so, sometimes it’s a syntax thing…

@AlexB

Yes, you definitely have to make sure the data gets refreshed when make changes in the background.

I’m glad it worked out for you.

1 Like

@AlexL Yup, it’s all good now. This makes my day.

For anyone else looking into this thread, here’s what worked for me:

if(INPUT=="")
“False”;
else
"True";

The only difference is the quotes around the True/False.

2 Likes

Just a quick note for later (year 2023+) editors, I wasn’t able to get the above to work until I changed the “” in the first line to simply null (with no quotes):

if(INPUT==null)
“False”;
else
“True”;

Wow, this post has been buried a long time!

Alternatively, below is what I use on a daily basis. I ‘think’ I had troubles with the previous when working with tablets, and this solution seems to work for all:

if (INPUT.length < 1)
false;
else
true;

4 Likes