Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Dynamically Change ComboBox DataSource to Another Column After Publishing

Posted on 21 Nov 2024 05:37:09 by

Hello Power Apps Community,

I am working on a Power Apps canvas application. In my form (screenshot attached), I have a ComboBox bound to a specific column in my data source. However, after publishing the app, It will automatically change to another column like compliance ID ComboBox to dynamically display data from a different column based on user input or other conditions.

For example, in the "District" field in the screenshot, I want it to initially display data from "Column A." After publishing, it automatically fetch another data from "Column B" instead.

Could you guide me on how to achieve this? Should I modify the Items property of the ComboBox, or is there another best practice for this scenario?

Any examples or steps would be greatly appreciated!

Thanks in advance!

Categories:
  • Suggested answer
    ronaldwalcott Profile Picture
    ronaldwalcott 764 on 26 Nov 2024 at 01:13:01
    Dynamically Change ComboBox DataSource to Another Column After Publishing
    Is this really what you want to do? Sounds like a recipe for data integrity issues.
     
    Are you saying that you have a column bound to a combobox and you want to conditionally set the items that can be selected but there isn't a relationship between the items. 
    This seems implied here

    I have a ComboBox bound to a specific column in my data source. However, after publishing the app, It will automatically change to another column like compliance ID ComboBox to dynamically display data from a different column based on user input or other conditions.

     
    Or do you want to display comboboxes in the same location on the screen bound to different columns. You would set the visibility based off some condition or user input?
  • Suggested answer
    SaiRT14 Profile Picture
    SaiRT14 911 on 26 Nov 2024 at 00:53:04
    Dynamically Change ComboBox DataSource to Another Column After Publishing
    pls try below steps:

    Use a variable to track which column or data source the ComboBox should display. Update this variable based on user actions or app logic. UpdateContext({ SelectedColumn: "ColumnA" })
     
    Use an If statement in the Items property to dynamically determine the data source or column based on the variable. If(
        SelectedColumn = "ColumnA",
        Filter(DataSource, ColumnA <> Blank()), // Display data from ColumnA
        Filter(DataSource, ColumnB <> Blank()) // Display data from ColumnB
    )
     
    Use a control like a Dropdown or Button to change the SelectedColumn variable dynamically. OnChange = UpdateContext({ SelectedColumn: Dropdown1.Selected.Value })
     
    Initialize the SelectedColumn variable in the app’s OnStart property to set the default column. Set(SelectedColumn, "ColumnA")
     
     
     

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,129

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,797

Leaderboard