web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Button Visibility If D...
Power Apps
Answered

Button Visibility If Data Is Blank

(0) ShareShare
ReportReport
Posted on by 329

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

Categories:
  • wyotim Profile Picture
    2,545 on at

    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.

  • BrendonBrooksP1 Profile Picture
    329 on at

    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. 

  • wyotim Profile Picture
    2,545 on at

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

  • BrendonBrooksP1 Profile Picture
    329 on at

    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

     

     

  • wyotim Profile Picture
    2,545 on at

    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.

     

     

  • BrendonBrooksP1 Profile Picture
    329 on at

    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? 

  • Verified answer
    wyotim Profile Picture
    2,545 on at

    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*

  • BrendonBrooksP1 Profile Picture
    329 on at

    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

  • wyotim Profile Picture
    2,545 on at

    Happy I could help out!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 283

#3
Mohsin Ali Profile Picture

Mohsin Ali 221

Last 30 days Overall leaderboard