cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
llserra
Helper III
Helper III

Get a list of days from a range of values ,from sharepoint

Hi

I have a CalendarGallery and i would like to mark in a Red color ,a selected days that one resource it's reservated.

I think a a good idea it with:

 

UpdateContext({_holidays:Table(
{HolidayDate:Date(2020;11;05)}
)
});;

 

The problem is that i have in a sharepoint list this:

 

DateStart               DateEnd                  Resource

08/11/2020  8:00   11/11/2020 14:00    Car1

08/11/2020  8:00    08/11/2020  14:00  Car2

12/11/2020  9:00    13/11/2020  8:00    Car1


I would like to recive por example of Car1 ,i don't care about hours

08/11/2020;09/11/2020;10/11/2020;11/11/2020;12/11/2020;13/11/2020

 

To pass this list to Hollydaysdate and get in my calendar all days that Car1 it's reserved in red.

 

So ,does anybody know how i can get this list?

 

Thanks for all help

7 REPLIES 7
mdevaney
Super User
Super User

@llserra 

I assume there is a text box inside the gallery gallery showing the date.  To turn the text box red on dates where the car is already reserved do this.

 

If(
    LookUp(
        your_reservations_table,
        DateStart <= ThisItem.Date
        And DateEnd >= ThisItem.Date
        And Resource = "Car1"
    )=Blank(),
    White,
    Red
)

 



---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Thanks it's a good idea, but not for my calendar... i have this:

 

calendar1.JPG

 

with this propeirties:

 

Collect(AvailableOptions; {Pressed: Button2.Pressed});;If(!_initialized;
UpdateContext({_today:Today()});;
UpdateContext({_firstDayOfMonth:DateAdd(_today;1-Day(_today);Days)});;
UpdateContext({_firstDayInView:DateAdd(_firstDayOfMonth;-(Mod(Weekday(_firstDayOfMonth)-2;7)+1);Days)});;
UpdateContext({_holidays:Table({HolidayDate:Date(2016;12;25)};
{HolidayDate:Date(2017;11;23)};
{HolidayDate:Date(2017;11;24)};
{HolidayDate:Date(2020;11;06)}
)
});;
UpdateContext({_initialized:true})
);

With holidaysTable if i pass all list of 08/11/2020;09/11/2020;10/11/2020;11/11/2020;12/11/2020;13/11/2020 days in my calendar show this days in red ,so it's working...

 

UpdateContext({_holidays:Table(
{HolidayDate:Date(2020;11;08)};
{HolidayDate:Date(2020;11;09);
{HolidayDate:Date(2020;11;10)

.....

{HolidayDate:Date(2020;11;13)

)
});;

 

The problem is that i don't know to get this list from sharepoint to get all days that one recurse it's reserved.

 

Sharepoint:

 

DateStart               DateEnd                  Resource

08/11/2020  8:00   11/11/2020 14:00    Car1

08/11/2020  8:00    08/11/2020  14:00  Car2

12/11/2020  9:00    13/11/2020  8:00    Car1

 

 

rizkyaditya
Resolver III
Resolver III

Hello @llserra ,

I assume you have this list :

DateStart               DateEnd                  Resource

08/11/2020  8:00   11/11/2020 14:00    Car1

08/11/2020  8:00    08/11/2020  14:00  Car2

12/11/2020  9:00    13/11/2020  8:00    Car1

And then you want to achieve this : 08/11/2020;09/11/2020;10/11/2020;11/11/2020;12/11/2020;13/11/2020 in your powerapps.

 

I think I was able to simulate your needs.

These are what you need :

  1. Your current sharepoint list data
  2. Table for looping to use later (I will explain later why you would need this)

 

And this is just my idea :

  • I use gallery with the exact data as you share here, and filter it with a Dropdown
     
     
     
     

image.png

  • The lower gallery there is just to show the filtered value(s)

So, here goes the code :

/*FIRST STEP*/
//Create Collection For Filtered Calendar Items, and sort it by the start date
ClearCollect(collectCalendarFiltered,SortByColumns(Filter(YourListName,Resource = Dropdown1.Selected.Result),"Start",Ascending));

 

/*SECOND STEP*/
//After you get the filtered list with sorted date, you need to create variable for the maximum data count that you need
//In this case for Car1, if it starts in 11/08/2020 and end in 11/13/2020, it means you need 6 date data to be stored
//I suggest you use DateDiff function and add it by 1
Set(varMaxCount,DateDiff(First(collectCalendarFiltered).Start,Last(collectCalendarFiltered).End)+1);

 

/*THIRD STEP*/
//Now you get filtered data, and your maximum data count, we will need that table that consist only one column and each rows with the possibility of your maximum datacount
//This table is used for the looping process to create each date between the selected range (as i mentioned before, this is the step that you will need the table)
//And then you create a Collection that consist only a column with each row indicating date from first to the last (starts in 11/08/2020 and end in 11/13/2020)
Clear(collectDateString);
ForAll(Filter(loopTable,Number<=varMaxCount),Collect(collectDateString,Text(First(collectCalendarFiltered).Start + Number -1)));

 

/*FOURTH STEP*/
//After you get the date range only collection, you just need to present it in a text way using Concat Function
//I set variable to put it into a Label text property
Set(varDateString,Left(Concat(collectDateString,Value & ","),Len(Concat(collectDateString,Value & ","))-1))

 

 

 

Please mark as solution if this suggestion can meet your requirement!

 

Best regards,

 

Rizky - Indonesia

rizkyaditya
Resolver III
Resolver III

Hello @llserra ,

After re-reading your needs, I think it is enough for you to use the step up to the third one.
Because I realized that you need Table to be passed to your _holidays: variable.

You can replace the third step with this :

/*THIRD STEP*/
//Now you get filtered data, and your maximum data count, we will need that table that consist only one column and each rows with the possibility of your maximum datacount
//This table is used for the looping process to create each date between the selected range
//And then you create a Collection that consist only a column with each row indicating date from first to the last (starts in 11/08/2020 and end in 11/13/2020)
Clear(collectHolidaysDate);
ForAll(Filter(loopTable,Number<=varMaxCount),Collect(collectHolidaysDate,DateAdd(First(collectCalendarFiltered).Start,Number-1,Days)));


The collection collectHolidaysDate  is already in table format.


image.png

 

 

Please mark as solution if this suggestion can meet your requirement!

 

Best regards,

 

Rizky - Indonesia

 

llserra
Helper III
Helper III

HI, thanks sorry to be late ,i answered you but i don't know whats happed but my answer was not saved...

 

Thanks for your answer ,its really a good idea but i have an error ,it's for the table looptable ,how i have to create? ,i used my sharepointlist but it's wrong... 


Thanks for all



 

 



Hello @llserra ,

 

The loopTable is basically just collection in my test app.

You can create it this way using the OnVisible property of your screen :

ClearCollect(loopTable,
Table(
    {Number: 1},
    {Number: 2},
    {Number: 3},
    {Number: 4},
    {Number: 5},
    {Number: 6},
    {Number: 7},
    {Number: 8},
    {Number: 9},
    {Number: 10}
))

 

This is how it looks like.

rizkyaditya_0-1605488007084.png

 

 

That is the example of how I create loopTable.

Number represent the column, and after that, the value in each row.

But the items there, as i said before, it is depend on how many days the customer will possibly rent the car.

If in the reality, the maximum renting days only around 20 days, then you can make the loopTable maximum to 30 just in case there are special case.

And for the syntax, i suggest you can stop at my third step.

rizkyaditya_1-1605488195667.png

 

Because as you explained, what you need for your calendar is a table.

llserra
Helper III
Helper III

Hi ,thanks ,but i don't know why but always in collectHolidaysDate i recive 26/07/2020 8:00;27/07/2020 8:00;28/07/2020 8:00;29/07/2020 8:00.....

But for example for recurse Adams it's:

FechaReserva (start) FechaDevolucion(End) Recurse

26/08/2020..................26/08/2020.......................Adams *

08/10/2020...................08/10/2020......................Adams *

24/11/2020...................27/11/2020......................Adams

*) Get and back in the same day

 

Also in:

looptable it's: 1,2,3,4,5.....

varMaxCount:94

 

Really i can see where it's wrong... 

 

thanks

 

ClearCollect(
    loopTable;
    Table(
        {Number: 1};
        {Number: 2};
        {Number: 3};
        {Number: 4};
        {Number: 5};
        {Number: 6};
        {Number: 7};
        {Number: 8};
        {Number: 9};
        {Number: 10};
        {Number: 11};
        {Number: 12};
        {Number: 13};
        {Number: 14};
        {Number: 15};
        {Number: 16};
        {Number: 17};
        {Number: 18}
    )
);;
// Set(Number,1);
ClearCollect(
    collectCalendarFiltered;
    SortByColumns(
        Filter(
            HistoricoReservas;
            NombreRecurso = Dropdown3.Selected.Nombre_x0020_Recurso
        );
        "FechaReserva";
        Ascending
    )
);;
Set(
    varMaxCount;
    DateDiff(
        First(collectCalendarFiltered).FechaReserva;
        Last(collectCalendarFiltered).FechaDevolucion
    ) + 1
);;
//Clear(collectDateString);
Clear(collectHolidaysDate);;
//ForAll(Filter(loopTable,Number<=varMaxCount),Collect(collectDateString,Text(First(collectCalendarFiltered).FechaReserva+Number-1)));
ForAll(
    Filter(
        loopTable;
        Number <= varMaxCount
    );
    Collect(
        collectHolidaysDate;
        DateAdd(
            First(collectCalendarFiltered).FechaReserva;
            Number - 1;
            Days
        )
    )
);;

 

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!      

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Community Roundup: A Look Back at Our Last 10 Tuesday Tips

As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience!   Getting Started in the Community An overview of everything you need to know about navigating the community on one page!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Thank you for being an integral part of our journey.   Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Top Solution Authors
Top Kudoed Authors
Users online (3,836)