Problems with Show if

Hi, I’m new to Appsheet.
I have built a prototype app to help clients record gas and electricity meter readings. There are three tables, Sites, Electricity Readings and Gas Readings. The two reading tables reference the Sites table and are each set to be “part of” that table. Broadly speaking, the app works but I want to refine it and am having problems with “show if” logic.

There is a column is Sites called Utility and for each row it contains "Electricity" or "Gas". There are rows in Sites for each site/utility combination and I have concatenated in Excel Site name and utility and set that as the key.

There is also column in Sites named Profile of type Text.

I have created form view for each reading table and set them as inline so if you click on a site it takes you to the inline views for electricity and for gas. However, if the site I click on is for electricity only, I want to show only the electricity inline form and vice versa. I am trying to use show if logic and have tried = and contains(). Each is accepted as correct but neither works.

For electricity if the profile is "04", I want to ask for a Day reading and a Night reading else Day only.

Can someone help, please?

Hi @Denis! I’m not sure if I have enough knowledge to help but I’d like to try. My problem is that I’m having trouble visualizing your situation, even though you have described it in detail. I wonder if you could provide some screenshots that you think might be illustrative of your problem.

I’m imagining that you have made actions that you have set to “inline.” Is that right? If so, are you relying on “show if” in the action itself or have are you using the “show if” setting in the table?

Kirk,

Thanks for coming back to me. I can build some screenshots for sure but, as this is a prototype with dummy data can I share it so you get the editor’s view? Which would be better?

Best wishes,

Denis

I’ve gone ahead and shared it with you as co-author so you can see my edit.

Many thanks again,

Denis

Thanks! This is the first time anyone has shared an app with me and I’m not quite sure how it works. I looked at my Gmail and at my AppSheet editor but didn’t see anything.

Hi @Kirk_Masden Check your "My Apps " page and scroll down to “Shared Apps” , you should see @Denis app there.

Thanks @Lynn! I guess the share didn’t work because I only have “Deployed” and “Prototype” as visible categories. :slightly_frowning_face:

Kirk,

I attach some screenshots that I hope will help.

Kind regards,

Denis

Lynn,

Thanks for trying.

Denis

1 Like

@Denis - maybe easiest is to just post the actual ShowIf formula you have in each of the virtual columns (Related Records…)? This should work but need to see the exact ShowIf to allow others to spot possible issues?

1 Like

Thanks @Denis! The images helped me get a clearer idea of what the problem might be. I’m guessing that the expression you are using as your “show if” condition needs to look for data in another table and that is what is failing. To be honest, however, I’m in over my head at this point. I’m hoping that @Aleksi, AppSheet’s expression wizard (who has helped me a lot – thanks again, @Aleksi!) will take a look at the expression you’re using and give us some advice.

By the way, your screenshots have helped me understand your situation much better than I understood it before but I have a suggestion that will make any future screenshots even easier to understand. First, when you take a screenshot of how something looks in your app, be sure to include the indication toward the bottom of the screen of what table the screenshot is based on. Here’s an example:

33

This “Data” indication is in the app editor but not in the app itself. So, a screenshot from the app editor can be more useful.

Similarly, when you show an expression, let us know where (that is, in which table) the expression is located. If I get confused about the table locations, that confusion makes it hard for me to give you a helpful answer.

Good luck!

Here are some screenshots. I will also post to site.

Thanks,

Denis

Hi @Denis What happens if you use 04 instead of “04” ?

Hi Lynn,

Makes no difference.

Denis

What is the name of the table in which

contains((sites[profile]),“04”)

is used? If you can reference a column in the same table, it should be easy. As I wrote before, I think it may be a bit harder when the condition depends on another table.

By the way, in your original explanation of the problem, “Sites” is capitalized but here it is lower case. I’m pretty sure the expressions are case sensitive, are they not? So that might be a problem.

Or, I see “Site” (not “sites”) so spelling might be a problem.

Finally, since sharing the app with me didn’t work, let me suggest another alternative. Make a copy of the app, delete any sensitive information from the tables, and then share it on your portfolio page.

To do this, you need to go to “Manage” in the AppSheet editor, then, under “Deploy” you “Deploy” your app. Then, go to “Author” (also in “Manage”) and make your app a public sample. Then if you tell us the address of your portfolio page, we can check it out.

The address of your portfolio page is

https://www.appsheet.com/portfolio/” + your AppSheet ID. My AppSheet ID is 230844 so my portfolio page is:

https://www.appsheet.com/portfolio/230844

The format for CONTAINS() is:

CONTAINS( whole-text , partial-text )

which answers the question: does whole-text contain partial-text?

The whole-text argument should be an expression that produces a single Text value. In the Show? expression for the Night Read column of the Electricity Meter Readings table, you have:

contains((sites[profile]),"04")

sites[profile] is a column list expression, producing a List of the values of the profile column from all rows of the table, which I suspect is not your intention. If you only want to look at the profile column value for the current row, instead use:

contains([profile],"04")

Based on your earlier statement:

I would guess profile would be exactly 04, rather than containing it in some longer text value. If so, I propose using = rather than CONTAINS():

([profile] = "04")

The = operator in AppSheet has some peculiar behavior that might cause a problem here, though: if the value on the left side of = is blank, the result of the = comparison will be TRUE regardless of the right side value. If the profile column might ever be blank, this expression might unexpectedly be TRUE. So it’s a good idea to ensure the left side value is not blank:

and(
  isnotblank([profile]),
  ([profile] = "04")
)
1 Like

The table is “Electricity Meter Readings” but I will also share the app through the portfolio page.

Many thanks,

Denis

Steve,

This doesn’t make any difference (Sorry if I’ve duplicated an email).

Denis

Kirk,

Mine is a prototype so It tells me I cannot deploy.

Denis

Neither table names nor column names are case-sensitive.

1 Like