1

I am new to powerapps and I've created an app based off of a sharepoint list.

The sharepoint list basically has 2 columns, date and color. Color is a choice of green, orange, yellow and red.

I've made an app where the user can choose the date and a color for that day. It works well, and I have the browse screen showing everybody's choices for that day.

I would like to now create a new screen where a small square of the chose color gets added and you can see all colors (so all squares) added for the last week, with the squares all right next to one another.

I would like to do it for the last year, as well, and ultimately make a date picker.

I'm having trouble figuring out how to do the "square creation" part and the formula to show the squares for the last week.

Should I create a second browse screen?

Really appreciate the help!

Thanks

GOB
  • 143
  • 10

1 Answers1

1

You can use a vertical gallery with the WrapCount property set to the number of columns that you want to display in your colors. In the example below, the gallery has a WrapCount property of 4:

Gallery of colors

And in the gallery there is a single Rectangle control, with the following expression for its Fill property:

Switch(
    ThisItem.Color,
    "green", Color.Green,
    "orange", Color.Orange,
    "yellow", Color.Yellow,
    Color.Red)

Notice that you will have to update it to match the schema in your SP list (and make it prettier than my quick example :-).

If you want to display all items from the past week, you can use something like the example below, in which we have a horizontal gallery, and inside of it, we have a vertical gallery:

enter image description here

These are the controls involved in this example, and some of their properties:

  • OuterGallery
    • Items: ForAll(Sequence(7, -6), { Date: DateAdd(Today(), Value) })
    • Children:
      • Label (for the day of the week)
        • Text: Index(Calendar.WeekdaysShort(), Weekday(ThisItem.Date)).Value
      • InnerGallery
        • Items: Filter(MySPList, Date = ThisItem.Date)
        • TemplateSize: 40
        • TemplatePadding: 1
        • Children:
          • Rectangle (for the color)
            • Width: Parent.TemplateWidth
            • Height: Parent.TemplateHeight
            • Fill: Switch( ThisItem.Color, "green", Color.Green, "orange", Color.Orange, "yellow", Color.Yellow, Color.Red)

As usual, you can always update how things are displayed (sort colors, change layout), but that should give you a starting point.

carlosfigueira
  • 85,035
  • 14
  • 131
  • 171
  • Thanks for the reply, much appreciated. I'll try this, I have to wrap my head around if it will be the correct solution. The goal is to show the change in colors over time, and each day may have a different number of entries. So for instance if I am showing a week's worth of data, there would be 7 columns and each column is a day with possibly a different number of rows. Right now I have a messy solution where I put 7 galleries in and made them narrow. I have already been using the switch code you mention. Thanks again. – GOB Oct 23 '22 at 02:02
  • 1
    Updated the answer with a way to show the colors for each day in the previous week – carlosfigueira Oct 24 '22 at 21:57
  • This is awesome, really appreciate the help. It took me a few tries to do everything, but got it! Only thing I would want to add now is to group the like colors together in the vertical column. I'll try to figure that out now. I tried using Sort but I get a delegation error. Any tips? – GOB Oct 25 '22 at 03:17
  • The delegation is a warning - not an error - which indicates that if you have more than 500 (up to 2000, it's configurable) items, it may not work properly. If the number of items being sorted (i.e., number of items on each day) is less than that, then you should be fine. See https://learn.microsoft.com/power-apps/maker/canvas-apps/delegation-overview for more details. – carlosfigueira Oct 25 '22 at 13:12
  • got it. Only reason I ask is because sometimes I get strange behavior that when I add an item to the list to a past date, the data on the current date sometimes gets altered (a color gets deleted) – GOB Oct 25 '22 at 21:53