cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Alex_Security
Resolver I
Resolver I

ShowColumns/DropColumns based on ComboBox.SelectedItems or Concat(ComboBox.SelectedItems)

Hi There,

 

hoping this forum can help. I'm trying to create a canvas app from a table that has a standard set of features (under heading features, the list of features then in a row of column A) and then each corresponding column is a technology (where the column heading is the name) that either has a yes or no in that column corresponding to the row of the feature, like this:

FeatureTech ATech BTech C
Feature 1YesNoYes
Feature 2NoNoYes

 

what i'm trying to do is let the user select the tech they want to see a comparison of via either checkboxes or a combo box (combo box made more sense to me) and then create either a gallery or table in PA to then spit out into HTML. 

 

its essentially a case of dropping/showing columns of the data source depending on whether the column is selected or not. I've tried both drop and show columns, but neither want to add or remove based off either the combobox input directly (using ComboboxName.SelectedItems.Value) or the Concat of the Combobox (using Concat(ComboboxName.SelectedItems,Value,",")). I have been able to successfully run an IF function out of the Concat to feed into... something... using initially the Concat, then If(Find("Tech A",ConcatLabel.Text)=1,"Tech A") but this still won't feed into either a drop column or show column.

 

also been trying to think of ways to do this in flow as well as PA, but still coming up blank. any help?

 

Thanks,

 

Alex.

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@Alex_Security 

So, this is relatively challenging in PowerApps (from a table perspective).  The reason is that you are trying to dynamically change a record schema, and you can't do that in PowerApps.  You're also trying to reference a column by its text name...this also cannot be done in PowerApps.

 

Now, that said...you can do many ways to get around it, but it takes some work.

 

Consider the following - a ListBox (I used a list box as it was easier to manipulate, combobox works fine too). with the names of the Columns you want to view in it.  In your case: ["TechA", "TechB", "TechC"]

In a Gallery, the following Formula:

ForAll(
    yourData,
    {Feature: Feature,
     Columns: 
         Concat(Sort(["TechA", "TechB", "TechC"], Value), 
             If(Value in Sort(ListBox1.SelectedItems, Value), Value & "|" & 
                 Switch(Value,
                     "TechA", TechA,
                     "TechB", TechB,
                     "TechC", TechC
                 ) & "~"
             )
          )
    }    
)
     

You can see the above it the manual part and painful if there are a lot of columns.

 

Now, in the Gallery, a Label with ThisItem.Feature for the Text property.

And a horizontal Gallery in the Vertical gallery with an Items property of: 

Filter(Split(ThisItem.Columns, "~"), !IsBlank(Result))

In the Horizontal Gallery, a label with the text property of : Last(Split(ThisItem.Result, "|")).Result

 

To give it a header, another Gallery, outside of the main one and on top.  Gallery Items property set to:

SortByColumns(ListBox1.SelectedItems, "Value")

And a Label in the Gallery with the Text property of : ThisItem.Value

 

Final result is this:

alex_security.gif

 

I hope I read what you were looking for properly and that this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

2 REPLIES 2
RandyHayes
Super User III
Super User III

@Alex_Security 

So, this is relatively challenging in PowerApps (from a table perspective).  The reason is that you are trying to dynamically change a record schema, and you can't do that in PowerApps.  You're also trying to reference a column by its text name...this also cannot be done in PowerApps.

 

Now, that said...you can do many ways to get around it, but it takes some work.

 

Consider the following - a ListBox (I used a list box as it was easier to manipulate, combobox works fine too). with the names of the Columns you want to view in it.  In your case: ["TechA", "TechB", "TechC"]

In a Gallery, the following Formula:

ForAll(
    yourData,
    {Feature: Feature,
     Columns: 
         Concat(Sort(["TechA", "TechB", "TechC"], Value), 
             If(Value in Sort(ListBox1.SelectedItems, Value), Value & "|" & 
                 Switch(Value,
                     "TechA", TechA,
                     "TechB", TechB,
                     "TechC", TechC
                 ) & "~"
             )
          )
    }    
)
     

You can see the above it the manual part and painful if there are a lot of columns.

 

Now, in the Gallery, a Label with ThisItem.Feature for the Text property.

And a horizontal Gallery in the Vertical gallery with an Items property of: 

Filter(Split(ThisItem.Columns, "~"), !IsBlank(Result))

In the Horizontal Gallery, a label with the text property of : Last(Split(ThisItem.Result, "|")).Result

 

To give it a header, another Gallery, outside of the main one and on top.  Gallery Items property set to:

SortByColumns(ListBox1.SelectedItems, "Value")

And a Label in the Gallery with the Text property of : ThisItem.Value

 

Final result is this:

alex_security.gif

 

I hope I read what you were looking for properly and that this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

Hi @RandyHayes, so gave that a test and it does indeed work. I'm working on a mobile app so the horizontal layered galleries were tricky, but i've also now worked out a HTML template using IF functions on the FIND of the Concat label, but your solution is about a million times more elegant! 

 

thanks so much! 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,758)