web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Conditional Formating ...
Power Apps
Answered

Conditional Formating based on day of week and scheduled work location

(0) ShareShare
ReportReport
Posted on by

Hello,

 

I am trying to incorporate "Work Location" into a seating chart app that I built previously.  My thought was to dynamically change the user label color based on the user's work location for the current day (ie: HQ = Green, WFH = Purple).  So for instance, if today were Wednesday, the label text color for Jon would be green and Mike would be purple. I have gathered the schedule information and placed it into a new Dataverse table (shown below).

 

jonfuego_0-1701215011353.png

 

The label to be changed is part of a gallery that displays the User and the Desk Location. 

jonfuego_1-1701216420532.png

This data is pulled from a collection, created from the Office365 connector:

 

ClearCollect(
    col_Users,
    Filter(
        Office365Users.SearchUser({top: 999}),
        OfficeLocation <> Blank()
    )
 
 
I am then looking up the label info as follows:
 
LookUp(
    col_Users,
    OfficeLocation = ThisItem.locName,
    DisplayName
)
 
 
My thinking is to use a Lookup against the Dataverse table to find the user based on DisplayName (lbl_User_FL1) and then change the text color based on the information in the Dataverse column for the current day.
 
I have run myself in circles trying to use Switch and Lookup, but I just cannot seem to get it right....
 
Any help is appreciated.
 
JF
 
 
 
 
 
 
 
 
 
 
 
 
Categories:
I have the same question (0)
  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @jonfuego,

    You need to check the weekday of today and retrieve location name based on it from Dataverse table.

     

    Please check as below:

    1). Populate the Gallery with this collection

    2). Set the Label Text property as below:

    Switch(Weekday(Today()),
     1,
    LookUp(
     'User Work Schedules',
     'User ID'= ThisItem.DisplayName,
    ).Monday,
    2,
    LookUp(
     'User Work Schedules',
     'User ID'= ThisItem.DisplayName,
    ).Tuesday,
    ...
    )

    3). Set the Fill property of Label as:

    If(Self.Text="HQ" ,Color.Green, Self.Text="WFH",Color.Purple)
  • jonfuego Profile Picture
    on at

     @v-qiaqi-msft Thank you very much for your reply.  I am not sure I am following you.  To clarify, are you saying, create a new gallery based on the User Work Schedules table?

     

     

    To add a bit more detail.  Here is what I thought would work, but I am getting an error that the Switch function has invalid arguments.

     

    Switch(
        Text(Weekday(Today())),
        "1", // Monday
        Switch(LookUp('User Work Schedules', 'User ID' = lbl_User_FL1.Text).Monday,
            "HQ", Color.Green,
            "DT", Color.DarkOrange,
            "BIA", Color.LightBlue,
            "WFH", Color.Purple,
            varColor
        ),
        "2", // Tuesday
        Switch(LookUp('User Work Schedules', 'User ID' = lbl_User_FL1.Text).Tuesday,
            "HQ", Color.Green,
            "DT", Color.DarkOrange,
            "BIA", Color.LightBlue,
            "WFH", Color.Purple,
            varColor
        ),
        "3", // Wednesday
        Switch(LookUp('User Work Schedules', 'User ID' = lbl_User_FL1.Text).Wednesday,
            "HQ", Color.Green,
            "DT", Color.DarkOrange,
            "BIA", Color.LightBlue,
            "WFH", Color.Purple,
            varColor
        ),
        "4", // Thursday
        Switch(LookUp('User Work Schedules', 'User ID' = lbl_User_FL1.Text).Thursday,
            "HQ", Color.Green,
            "DT", Color.DarkOrange,
            "BIA", Color.LightBlue,
            "WFH", Color.Purple,
            varColor
        ),
        "5", // Friday
        Switch(LookUp('User Work Schedules', 'User ID' = lbl_User_FL1.Text).Friday,
            "HQ", Color.Green,
            "DT", Color.DarkOrange,
            "BIA", Color.LightBlue,
            "WFH", Color.Purple,
            varColor
        ),
         RGBA(0, 0, 0, 1) // Default color if no match
    )
  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @jonfuego

    No, your provided formula is wrong in logic....

    You have collected all the users in your Gallery, so each record represents a single user, if I understand correctly, you want to display the label color based on the weekday of today, well, then you just need to check the weekday of the current day, if it is monday, go to your Dataverse table, retrieve the location name based on the weekday column and user id.

     

    There is no need to use a nested Switch(), which is the error you have in your formula.

    Just try my formula.

  • jonfuego Profile Picture
    on at

    Thank you again for you assistance.  I don't think I explained my situation well enough though.  I am not looking to change the color based on what day of the week it is.  I want to change the color based on the location that they are at "Today", based on the Dataverse table.

  • jonfuego Profile Picture
    on at

    @v-qiaqi-msftFloating this back up because I realized that I did not describe my issue accurately.  Where I described the gallery data as coming from "col_Users", I was incorrect. 

     

    The gallery data is coming from a different collection entirely (col_Locations).  Therefore the User name is not actually in the gallery, and is instead populated by a lookup.  I am sure this is where my confusion is coming from.  This means, in your example, "ThisItem.DisplayName" is not a valid item.

     

     

  • Verified answer
    jonfuego Profile Picture
    on at

    I figured out my mistake.  I needed to nest a lookup inside my existing lookup to get the correct User ID

     
     
    Switch(
        Text(Weekday(Today())),
        "1",// Monday
        Switch(
            Text(
                LookUp(
                    'Employee Schedule',
                    'User ID' = LookUp(
                        col_Users,
                        OfficeLocation = ThisItem.locName,
                        DisplayName
                    )
                ).Monday
            ),
            "HQ",
            Color.Green,
            "DT",
            Color.DarkOrange,
            "BIA",
            Color.LightBlue,
            "WFH",
            Color.Purple,
            varColor
        ),
     
     
    Thank you again @v-qiaqi-msft for your offer of assistance.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard