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 / Hide a Data Table colu...
Power Apps
Answered

Hide a Data Table column based on contents?

(0) ShareShare
ReportReport
Posted on by 31

Has anyone ever hidden a column in a Data Table in a canvas Power App based on the absence / presence of values?

 

Like, when the user changes a filter on a Data Table such that the current set of records have no value in text Column 4...hide that field?  And show it when it again contains text values with length > 0?

Doesn't seem like a "thing" but wanted to check just in case.

Thanks!

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @breck 

    Yes, the column has a Visible property on it, you can set it to true or false as needed.

     

    I hope this is helpful for you.

  • MVP-Phipps Profile Picture
    3,521 Super User 2024 Season 1 on at

    Go to the Visibility property and set it to either true or false. If you have a variable you can also use the variable in this property to control the visibility. 

     

    Please Accept as Solution if it solves your question. Or just give it a Thumbs Up if it is helpful because this can help others.

    LinkedIn: https://www.linkedin.com/in/charlie-phipps-%F0%9F%91%A8%E2%80%8D%F0%9F%92%BB-91338715b/
    YouTube: https://www.youtube.com/channel/UChmFBGU1YKIU91sNMQ7buGg
    Twitter: https://twitter.com/phipps0218

  • breck Profile Picture
    31 on at

    Sorry, should've specified that I'm looking for some kind of syntax example.

    Here, SSCC_Column1 is a text field in the data table, and apparently I can't get this syntax correct.

    I've tried referencing the data table column (as I'm trying here) and also the data source field itself:

    (Max(Len(SSCC_Column1)) > 1)

    This is something I'm trying in the function for the Visible property.

    Thanks.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @breck 

    Is it that you are trying to automatically hide columns if there is no value in any record for that column?  If so, then you need to reference the datasource with your formula.

    i.e.

    CountRows(yourDataSource, !IsBlank(thisColumnName))>0

     

    This is all an example...the yourDataSource needs to be the Items of your datatable and...this would not be delegable, so if you are dealing with more records than your record limit set in the app, then another solution is needed.

  • breck Profile Picture
    31 on at

    So...my problem might be that if I throw something like this at it (just my current flailing around):

    If(CountIf(FirstN(sqlSourceData,10), !(IsBlank(sqlFieldName))) > 0, true, false)

    (with FirstN() there to try to take an early look and not bog down on record count)

    Really, my problem is that I've gotten my focus off of the Data Table (where the user has applied one to many filters on the source) and am targeting the source data.  

    The current data as displayed in the Data Table may or may not have data displayed in my target column, depending on what filters the user currently has in place.  And that's when I want to hide or show that column in the Data Table--show it when his/her filters cause it to reflect contents, and hide it when those filters won't.

    I could do some cludgier things to get this to happen, but it just requires my function to "know things it shouldn't" and I'd really rather rely on a simple look at any N of the currently-displayed values in that column to see if any of them have values with length > 0.  If they do, then show, and hide if not.

    This just may not be something attainable in the way I'm currently thinking about it.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @breck 

    Well, you're kind of talking about two different things (If I am reading it correctly), you are referring to a filtering ability and at the same time a show/hide capability for the table.  

    How does one impact the other?  Or, are they simply two different things?

     

    When you refer to "target column" what do you mean by that?

  • breck Profile Picture
    31 on at

    Filtering ability already in place.  Performed by the user on the Data Table.

    "Target column" to mean the column I'd like to show/hide based on whether the user's current set of filters causes non-zero-length data to appear in that column or not.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @breck 

    I'm not clearly understanding how the target column relates to the filter because I have no idea what your filtering is looking like and how it is designed. 

    Is it possible to provide a screenshot of that?

  • Verified answer
    breck Profile Picture
    31 on at

    So, this seems to be working now:

    If(CountIf(FirstN(
    (
    Filter(sqlSourceData, LineID = ddlLines.Selected.LineID
    And (!(toggleSpecDate.Value) Or ProducedDateText = Text(DatePicker1.SelectedDate, "mm/dd/yyyy"))
    And (!(toggleSpecProduct.Value) Or ProductCode = ddlProducts.Selected.ProductCode)
    And (txtFilter1.Text = "" Or txtFilter1.Text in LotNumber))
    )
    ,10), !(IsBlank(sqlFieldName))) > 0, true, false)

    I'm brand-new to Power Apps and I think one of my problems has been that there's not going to ever be the equivalent of a "DataTable1.CurrentData" property, where CurrentData would be the source (sql) data as currently displayed and filtered by the user.

    I'm always going to have to go "back to the well" and use my source data with all the relevant filters applied.  There's probably a way to create a variable or something that represents everything above supplied as the first parm to FirstN().  That would be cleaner than dragging around all these filters every time I wanted to represent the currently-displayed data someplace, and I could just change things in one place.

    Anyway, thanks so much for the help!

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @breck 

    Yes...you are stating that you are having to repeat the formula of your Items property of the datatable each time!

     

    There is a way to do this.  It is very little known in PowerApps!  It is what I call a dynamic record variable.

     

    There are steps involved in creating one - something you are interested in knowing??  I can elaborate. 

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard