cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BrendonBrooksP1
Post Patron
Post Patron

Button Visibility If Data Is Blank

Hello,

 

I'm trying to make a button disable or not visible if the there is no data within a data table.  I know that I have to change the Visible proptery of the Button. Could a simple If statement work for this scenario?

 

If(IsBlank(DataTable),false,true)

Would that work? Or do I really need a Context variable?

 

Brendon

1 ACCEPTED SOLUTION

Accepted Solutions

You are using a data table for each of those sections right? Are you using the data table to check for the data? If so, I don't think that it is possible like with a gallery. Galleries have an AllItems property that you can use to check for the existance of items but data tables don't have anything like that (that I am aware of anyway). That said, I think the way you are doing it is fine; we may just need to adjust the approach a bit. 

 

Maybe a filter on the collection or a lookup by the potential inspection item? Like:

 

/* Check for a date for an inspection item; if there is none show the button, otherwise hide the button */
If(
    IsBlank(
         LookUp(colCollectionOfData, Item = InspectionItem).Date
    ),
    true,
    false
)

 *edit for spelling*

View solution in original post

9 REPLIES 9
wyotim
Resident Rockstar
Resident Rockstar

An If statement should work though I think you might need to use the IsEmpty function instead of the IsBlank. Another thing you could do is check if CountRows(DataTable) = 0. And finally, you could shorten it to

!IsEmpty(DataTable)

// or //

CountRows(DataTable)<>0

as that should return true when there is data and false when there is not, removing the need for an If statement at all.

I'm afraid that neither of those worked. I tried the following

 

!IsEmpty(DataTable_2)

And i tried nesting it inside and If statement

If(IsEmpty(DataTable_2)false,true)

I'm confused because the suggested formual works on other pages. 

Could you maybe explain a bit of the scenario and where the button is? Is it in a gallery or something like that?

Sure. 

 

In the photo below, I have a screen for inspections. I had to make this as simple as possible, so I have seperate buttons for whatever type of inspection that needs to be done.  What I'd like to do is have them disabled or not visible if there's an item that does not need a specific type of inspection. 

 

What I'd like to accomplish, is to only display the buttons if there's a previous inspection date. This way users don't accidently push the wrong button or pass incorrect data.

buttons.PNG

 

 

To check my understanding, if a date shows up, like under PostUseDate for instance, you want the Post Use Inspection button to be hidden/disabled, right? 

 

How are you getting the data for those sections? Is that a single record that you are using or is it a collection of records that is just showing the most recent date for each item? I'm just trying to wrap my head around the data you are using to check against.

 

 

To check my understanding, if a date shows up, like under PostUseDate for instance, you want the Post Use Inspection button to be hidden/disabled, right? 

-Yes.

 

How are you getting the data for those sections? Is that a single record that you are using or is it a collection of records that is just showing the most recent date for each item? I'm just trying to wrap my head around the data you are using to check against.

-The data comes from a Collection, and each corresponding date is from a single record. My primary data source is from SQL.

 

Should I have used a Gallery to display data from a Collection? 

You are using a data table for each of those sections right? Are you using the data table to check for the data? If so, I don't think that it is possible like with a gallery. Galleries have an AllItems property that you can use to check for the existance of items but data tables don't have anything like that (that I am aware of anyway). That said, I think the way you are doing it is fine; we may just need to adjust the approach a bit. 

 

Maybe a filter on the collection or a lookup by the potential inspection item? Like:

 

/* Check for a date for an inspection item; if there is none show the button, otherwise hide the button */
If(
    IsBlank(
         LookUp(colCollectionOfData, Item = InspectionItem).Date
    ),
    true,
    false
)

 *edit for spelling*

View solution in original post

Yup. I'm using a data table for each one of those sections. I'm not sure if that's the most efficient way of this. 

 

That formula you suggested worked! I did modify it so that it queried the database directly, as opposed to the collection. I've been having a lot of problems with my Collections due to the limitations of how many records they can hold.  But that, is for another day. 

 

Thank you for your help! It's appreciated

 

-Brendon

Happy I could help out!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,339)