cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TimDemma
Helper II
Helper II

Conditional Button Coloring / Flow Chart type function

Hello all, 

 

So I have typically been about 90% successful with getting help from this forum when it comes to the struggles of building an app. But, my current issue has stumped me good. Here is what I am trying to do:

 

I want to have buttons 1, 2 and 3 to have a Green fill color until I click on them; then they will have a Red fill color. In addition to that, the arrows that stem from each button would also turn red or green based on the color of the button. (See 'capture.png' below) Another complication is that there will be more buttons and arrows like this, but when certain buttons are colored red, I would need them to cause other buttons below them to turn red as well. (See 'capture2.png' below.) 

Maybe this is too technical for PowerApps, but I'm sure there is some more knowledgeable user out there that can help. Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
SkiDK
Solution Sage
Solution Sage

I would use a collection to store the necessary data for each button. Store a record for each button containing: number, color and tier. By tier I mean the level of which the button(s) is located, so f.e. in your example: buttons 1 & 2 are tier 1, button 3 is tier 2, and if there is a button 4 and 5 under button 3 they get tier 3, and so on.

 

 

ClearCollect(
  colButtons,
  {
    Button: 1,
    Color: Green,
    Tier: 1
  },
  {
    Button: 2,
    Color: Green,
    Tier: 2
  },
  {
    Button: 3,
    Color: Green,
    Tier: 2
  }
)

 

If you press button 1, then update the collection to the right color for the button pressed and all tier with a higher number of the button. 

 

UpdateIf(
  colButtons,
  Tier >= LookUp(colButtons, Button = Self.Value, Tier), //Self.Value is the value of the button so f.e. 1
  {
    Color: Red
  }
)

 

In each button in the fill property you link to the record in the collection and retrieve color from there:

 

Fill = LookUp(colButtons, Button = Self.Value, Color)

 

This way when you click a button, all the higher tier buttons will get updated in the collection and all buttons should change color since they take the color value from that collection.

 

I hope this helps.

View solution in original post

2 REPLIES 2
_Nils_
Advocate I
Advocate I

Hello @TimDemma,

 

the only way I can think of would be to create a variable for every button which stores the information of which color the button is suppost to be.

 

OnSelect of the Button you would switch the variable to the other color.

 

Fill of the Button and color of the corresponding arrow(s) would then be a simple if-condition that looks at the variable and decides which color to pick, based on the value.

 

This same color condition could be used for other buttons below as well.

Fill on Button3 could be conditioned on the variable for Button1.

SkiDK
Solution Sage
Solution Sage

I would use a collection to store the necessary data for each button. Store a record for each button containing: number, color and tier. By tier I mean the level of which the button(s) is located, so f.e. in your example: buttons 1 & 2 are tier 1, button 3 is tier 2, and if there is a button 4 and 5 under button 3 they get tier 3, and so on.

 

 

ClearCollect(
  colButtons,
  {
    Button: 1,
    Color: Green,
    Tier: 1
  },
  {
    Button: 2,
    Color: Green,
    Tier: 2
  },
  {
    Button: 3,
    Color: Green,
    Tier: 2
  }
)

 

If you press button 1, then update the collection to the right color for the button pressed and all tier with a higher number of the button. 

 

UpdateIf(
  colButtons,
  Tier >= LookUp(colButtons, Button = Self.Value, Tier), //Self.Value is the value of the button so f.e. 1
  {
    Color: Red
  }
)

 

In each button in the fill property you link to the record in the collection and retrieve color from there:

 

Fill = LookUp(colButtons, Button = Self.Value, Color)

 

This way when you click a button, all the higher tier buttons will get updated in the collection and all buttons should change color since they take the color value from that collection.

 

I hope this helps.

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (3,276)