cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
OlaH
Resolver I
Resolver I

Show a textbox if it's Monday today

I've got a week schedule but don't want to show all the times of the week at the same time. So if it's Monday today, how show "15:40" in a textbox. I like to use weekdays instead of dates if possible.

The datasource looks like this:

 

weekschedule.png

1 ACCEPTED SOLUTION

Accepted Solutions
Meneghino
Community Champion
Community Champion

Hi, I assume you start with a date variable, MyDate, then you can use something like this:

If( Text(MyDate, "ddd", "en-GB") = "Mon", "15:40", Text(MyDate, "ddd", "en-GB") = "Tue", "16:20", Text(MyDate, "ddd", "en-GB") = "Fri", "15:20", "16:00")

Please let me know if it works as I am going from memory.  If you are in US you can use en-US instead of en-GB

 

Details here:

https://powerapps.microsoft.com/en-us/tutorials/show-text-dates-times/

View solution in original post

6 REPLIES 6
Meneghino
Community Champion
Community Champion

Hi, I assume you start with a date variable, MyDate, then you can use something like this:

If( Text(MyDate, "ddd", "en-GB") = "Mon", "15:40", Text(MyDate, "ddd", "en-GB") = "Tue", "16:20", Text(MyDate, "ddd", "en-GB") = "Fri", "15:20", "16:00")

Please let me know if it works as I am going from memory.  If you are in US you can use en-US instead of en-GB

 

Details here:

https://powerapps.microsoft.com/en-us/tutorials/show-text-dates-times/

Thank you @Meneghino!

 

And it's amazing what we can do, together (!), with PowerApps!

With @PKHong, as a "mentor", I've learned how to make my wish come true. 

PowerApps will truely be a game changer.

You can also try the Weekday() function. Assuming that the TextBox is part of a Gallery:

 

TextBox1.Text: 
ThisItem.Time

TextBox1.Visible:
Weekday(ThisItem.Date)<>2

I prefer to separate my Text and Visibility properties.

 

Or if you want to keep the TextBox visible for a single TextBox:

TextBox1.Text:
If(Weekday(MyDate)<>2,"15:40")
Microsoft Employee
@8bitclassroom

Thank you mr-dang for your suggestion and you efforts to guide all of us out here!

The code looks very neat but I can't get it to work. Probably cause I don't really understand it.

Yes, I want one textbox, visiable all the time but showing different times every day.

 

MyDate?

When I tried your second idea I got an error. I used my textbox, "DagTB", as "MyDate". Look at the picture down below.

Was that a misstake?

 

<>2

What does this do?

(I'm trying to learn and understand, not just making it work with your help.)  

 

Two datasources in one gallery?

I made it with Meneghino's suggestion but in that case I had all the times in the same datasource as the gallary. I'd rather have it in a another datasource, "Scehdule". Like in the picture above. Is that possible? 

What do I write instead of "15:30" in that case?

 

weekday.png

 

 

 

Hi @OlaH,

I forgot to explain how Weekday() worked in my last post. 

Weekday can detect which day of the week a given date is and it returns a number. 

 

Weekday(Today()) is going to return 1 since today is Sunday.

Sunday returns 1
Monday returns 2
Tuesday returns 3
Wednesday returns 4
Thursday returns 5
Friday returns 6
Saturday returns 7

There's more advanced things you can do with Weekday if you don't want 1 to be Sunday--like if you wanted 1 to be Monday. The Weekday() function can take the same arguments as it does in Microsoft Excel.

 

After seeing your picture, I think I know what you can do to show the only the times you want.

 

First, I made a mistake in my last post. I thought you wanted to show all the times that was NOT Monday. When you see the symbol "<>", that means Not. So I was using the formula to show all the times where the Weekday is not 2, which means Monday. As an aside, you can also use ! in front of arguments to also express Not.

 

Overall, you can ignore my last post since it would not apply to your situation.

 

For your situation, I assume you have one datasource with the names of all your employees, Employees, and you want to have a second datasource with the times, Schedule.

 

One best practice I would suggest is to write your Schedule table so that the name of the weekday is not the column name since it's hard to operate on the name of a column in PowerApps. Instead, if you place the names of the weekdays into records, you can detect them. I added a Code column to correspond to the name of the weekday. This makes it easier to look it up later.

Schedule

WkDay
TimeStart Code Monday 15:40 2 Tuesday 16:20 3 Wednesday 16:00 4 Thursday 16:00 5 Friday 15:20 6

 

You can set DagTB to be Today() or set it to a DatePicker1.SelectedDate depending on whether you want it to show today's date or a date you select in a date picker.

 

I am not sure how you have your Employees set up. I would set the Gallery1.Items to Filter your Employees to only show the ones who work on that day:

Filter(Employees, [condition that only shows employees who work on DagTB])

Inside Gallery1, set the TextBox you have for showing the Time to:

First(Filter(Schedule,Code=Weekday(DagTB))).TimeStart

This means, "In the TextBox, show the time for the first record in the Schedule datasource where the date in DagTB matches the Code column." So if DagTB is a date that is Wednesday, then Weekday(DagTB) will return 4, and look up 4 in the Code column in the Schedule datasource to return "16:00." 

 

The formula for time will work if all employees have the same time. If each employee has a different time, then some more information will be needed in the Schedule datasource.

 

 

Microsoft Employee
@8bitclassroom

Hi mr-dang

I love to learn and therefor I'm so greatful for all your guidance and know I understand Weekday() much better.

 

My app is for a after school center and the 250 kids ("Emplyees") have many different time that they leave. The solution I got from Meneghino gets the work done.

 

There is always a problem when we who needs help define the issu. Since we don't know what to do we often miss information thats needed. I'm sorry if I misslead you @mr-dang but want to thank you for sharing your knowledge.

 

Ola

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (918)