What I have using MOD kind of works however I would like to randomize the colors of the odd numbers as well. The goal is to quickly see color coded numbers in a details view.
The code below will match same Title (which is a number in this case) with the same color. The Mod function pulls all of the evens and set's their colors based on matching Title. The odd numbers are static one color, no randomizing (I would like to randomize this but match same Title colors). Hopefully this makes sense.
This is what I have:
If(
Mod(
ThisItem.Title,
2
) = 0,
RGBA(256*Rand(), 256*Rand(), 256*Rand(), 1)
)
Here are the results
Thanks in advance.
Solved! Go to Solution.
Hi @JSTechSand ,
I assume there is a collection:
Collect(
Mycollection,
{Title:1234,ID:1},
{Title:123451,ID:2},
{Title:123451,ID:3},
{Title:123451,ID:4},
{Title:123452,ID:5},
{Title:123453,ID:6},
{Title:123453,ID:7},
{Title:123454,ID:8}
)
You could try:
1\Set the gallery's items property to:
Ungroup(AddColumns(GroupBy(Mycollection,"Title","NewGroup"),"Color",RGBA(256*Rand(), 256*Rand(), 256*Rand(), 1)),"NewGroup")
2\Set the control's Fill property to:
If(
Mod(
ThisItem.Title,
2
) = 0,
RGBA(256*Rand(), 256*Rand(), 256*Rand(), 1),
ThisItem.Color
)
Best Regards,
Bof
Hi @JSTechSand ,
I assume there is a collection:
Collect(
Mycollection,
{Title:1234,ID:1},
{Title:123451,ID:2},
{Title:123451,ID:3},
{Title:123451,ID:4},
{Title:123452,ID:5},
{Title:123453,ID:6},
{Title:123453,ID:7},
{Title:123454,ID:8}
)
You could try:
1\Set the gallery's items property to:
Ungroup(AddColumns(GroupBy(Mycollection,"Title","NewGroup"),"Color",RGBA(256*Rand(), 256*Rand(), 256*Rand(), 1)),"NewGroup")
2\Set the control's Fill property to:
If(
Mod(
ThisItem.Title,
2
) = 0,
RGBA(256*Rand(), 256*Rand(), 256*Rand(), 1),
ThisItem.Color
)
Best Regards,
Bof
Thanks @v-bofeng-msft so the group works perfect, the rest of the columns stopped showing up... Not sure what happened there? This is an sp list. Is there something I'm missing? I'm also trying to sort them by a date field so this may be part of the issue?
Any ideas would be greatly appreciated! Thanks.
Hi @JSTechSand ,
Please show me more details. (detail settings, formula,screenshots)
Best Regards.
Bof
Hey @v-bofeng-msft no problem, Thanks.
Here's what I have currently in items of the browse gallery:
Sort(
[@'Shower Department'],
'INSTALL DATE',
Ascending
)
The app is sorted by due date to keep the most important items on top.
When I use the code you provided linked to the sp list:
Ungroup(
AddColumns(
GroupBy(
[@'Shower Department'],
"Title",
"NewGroup"
),
"Color",
RGBA(
256 * Rand(),
256 * Rand(),
256 * Rand(),
1
)
),
"NewGroup"
)
Title and a few other columns show up, here's an example of before:
And here is with the ungroup:
Using this code:
I hope this makes sense. I haven't been able to apply the sort by date. Can that be nested? Let me know if you need any additional information, and thanks for your help!
Hi @JSTechSand ,
The formula does not report an error, it seems that the error appears on other controls. Can you provide settings for these controls?
Best Regards,
Bof
@v-bofeng-msft I sent you a direct message with some more details, maybe due to using choice columns in the sp list?
Thanks for your help with this @v-bofeng-msft. There was a problem with the controls on my end, your solution worked out perfectly!
Here's an example, the commented control was the problem:
/ * "Small Parts: "& ThisItem.'STATUS - SMALL PARTS'.Value * /
"Small Parts: "& ThisItem.STATUS_x002d_SMALLPARTS.Value <-- this was correct
Trying to figure out how to sort this by the Installdate column now.
Any ideas?
Disregard, I figured out the sorting by date. Thanks again!
Working groupby with sort:
Sort(Ungroup(AddColumns(GroupBy([@'Shower Department'],"Title","NewGroup"),"Color",RGBA(256*Rand(),256*Rand(),256*Rand(),1)),"NewGroup"),INSTALLDATE,Ascending)
Maybe not @v-bofeng-msft, the sort worked ok and didn't give me any errors, however the color function is no longer grouped. Any ideas would be greatly appreciated! Thanks
User | Count |
---|---|
253 | |
113 | |
92 | |
48 | |
38 |