Forum Discussion
Filling a predefined value in a cell based on background color of another cell?
- Mar 20, 2023
magnusjonasson You have to use the calculated column formula in this format:
=IF([Justnupadatum] <= TODAY()-[Malantalbankdagar], "Not OK", IF([Justnupadatum] >= TODAY()-[Malantalbankdagar], "OK", ""))
Here you have to use the display names of columns instead of internal names. Also, if TODAY() does not work, try using NOW().
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs
magnusjonasson I forgot to change date column name in JSON conditions in above JSON. Use below JSON instead:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=if([$Justnupadatum] <= addDays(@now, -1 * [$M_x00e5_lantalbankdagar]), 'Not OK', if([$Justnupadatum] >= addDays(@now, -1 * [$M_x00e5_lantalbankdagar]), 'OK', ''))"
}
Use correct internal name of your date column in place of [$Justnupadatum] in above JSON.
Unfortunately, filtering/sorting will not work if you are using JSON to show values.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs
Is there any way to actually set a value for the Status cell based on background color of another cell, to be able to use it for filtering?
- ganeshsanapMar 20, 2023MVP
magnusjonasson Couple of options for this:
- Use calculated column for status - Note, you will not be able to change value via list forms later
- Use Power automate flow to change the status column value based on date column - you can run flow on item creation and/or item update for immediate update of status column OR scheduled flow to update status at certain times in a day.
- Customize list form using Power apps, update status column value using Power apps formulas based on date column value.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs
- magnusjonassonMar 20, 2023Copper ContributorYes, I'll look into using calculated columns. Thanks!
- ganeshsanapMar 20, 2023MVP
magnusjonasson You have to use the calculated column formula in this format:
=IF([Justnupadatum] <= TODAY()-[Malantalbankdagar], "Not OK", IF([Justnupadatum] >= TODAY()-[Malantalbankdagar], "OK", ""))
Here you have to use the display names of columns instead of internal names. Also, if TODAY() does not work, try using NOW().
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs