cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gymcode
Post Partisan
Post Partisan

How to Fetch More than 1 Value in a ForAll Formula

My following formula fetches 1 value, 'Reserved Desk'.Name.

ForAll(
    Filter(
        Reservations,
        'Reservations (Views)'.'Active Reservations',
        Date >= FromDate_Dp.Value,
        Date <= ToDate_Dp.Value && ('Status Reason' = 'Status Reason (Reservations)'.Blocked || 'Status Reason' = 'Status Reason (Reservations)'.Booked)
    ),
    'Reserved Desk'.Name
)

 

However, I am required to fetch an additional value, 'Status Reason (Reservations).

May I know how can this be done? Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi , @gymcode 

Sorry , i make a mistake , the previous code is your dropdown -items.

You can try to use this code :

 

 

Switch(
    LookUp(
     ForAll(
    Filter(
        Reservations,
        'Reservations (Views)'.'Active Reservations',
        Date >= FromDate_Dp.Value,
        Date <= ToDate_Dp.Value && ('Status Reason' = 'Status Reason (Reservations)'.Blocked || 'Status Reason' = 'Status Reason (Reservations)'.Booked)
    ),
    {DeskName:'Reserved Desk'.Name , StatusReson: Text(statuscode) }
)
, StatusReson  = ThisItem.Name
    ).'Booking Reason',
    "Booked",
    Color.Red,
    "1",
    Color.Red,
    "Blocked",
    Color.Gray,
    "864630000",
    Color.Gray,
    Color.Green
)

 

 

And you can also add a button in your Gallery and test if the code have the data return:

 

Set(testData,LookUp(
     ForAll(
    Filter(
        Reservations,
        'Reservations (Views)'.'Active Reservations',
        Date >= FromDate_Dp.Value,
        Date <= ToDate_Dp.Value && ('Status Reason' = 'Status Reason (Reservations)'.Blocked || 'Status Reason' = 'Status Reason (Reservations)'.Booked)
    ),
    {DeskName:'Reserved Desk'.Name , StatusReson: Text(statuscode) }
)
, StatusReson  = ThisItem.Name
    ).'Booking Reason')

 

And then click the button:

vyueyunmsft_0-1704965136075.png

And the logic is that this code will return the StatusReason if the current item in Gallery exist in the DropDpwn Items.
LookUp(Your Dropdown items Table , Fileld Name in Table =ThisItem.Field Name in Gallery Table).StatusReason

 

Then we can use Switch() function to judge:
Switch(StatusReason,"Match Value1","Return color1" ,"Match Value2","Return color2"  , "If all can not meet return value")

 

You can step by step to check that each of your tables is returning the correct data, and then check that the column names are being used correctly.
I'll OOF right away, and if you still have questions, I'll get back to you as soon as possible

 



Best Regards,

Yueyun Zhang

View solution in original post

17 REPLIES 17
v-yueyun-msft
Community Support
Community Support

Hi , @gymcode 

You can try to use this code :

 

ForAll(
    Filter(
        Reservations,
        'Reservations (Views)'.'Active Reservations',
        Date >= FromDate_Dp.Value,
        Date <= ToDate_Dp.Value && ('Status Reason' = 'Status Reason (Reservations)'.Blocked || 'Status Reason' = 'Status Reason (Reservations)'.Booked)
    ),
    {DeskName:'Reserved Desk'.Name , StatusReson:'Status Reason (Reservations)'}
)

 

 

ForAll( Table , {Column1(Custom ColumnName) : Value1(Value from your Table) , Column2(Custom ColumnName): Value2(Value from your Table)})

 

If this reply can help you , you can click mark this reply as solution, thanks in advance!


Best Regards,

Yueyun Zhang

 

-- duplicate reply--

Hi , @gymcode 

Can you try to use this code :

ForAll(
    Filter(
        Reservations,
        'Reservations (Views)'.'Active Reservations',
        Date >= FromDate_Dp.Value,
        Date <= ToDate_Dp.Value && ('Status Reason' = 'Status Reason (Reservations)'.Blocked || 'Status Reason' = 'Status Reason (Reservations)'.Booked)
    ),
    {DeskName:'Reserved Desk'.Name , StatusReson:Text('Status Reason (Reservations)'.Value)}
)

columnName.fieldName

 

If it still can not work , what's your data source and the column type ?

 

If this reply can help you , you can click mark this reply as solution, thanks in advance!


Best Regards,

Yueyun Zhang

 

Hi @v-yueyun-msft , thank you for your reply. I have formatted my Dropdownlist as follow (contain all Booked Desks with their Booking Status):

 

 

ForAll(
    Filter(
        Reservations,
        'Reservations (Views)'.'Active Reservations',
        Date >= FromDate_Dp.Value,
        Date <= ToDate_Dp.Value && ('Status Reason' = 'Status Reason (Reservations)'.Blocked || 'Status Reason' = 'Status Reason (Reservations)'.Booked)
    ),
    {
        DeskName: 'Reserved Desk'.Name,
        StatusReson: 'Status Reason (Reservations)'
    }
)

 

Edit: My data type for 'Status Reason (Reservations)' is OptionSet type.


I am able to fetch the column now, but I realized it is OptionSet so the data was not displayed, and is currently a limitation for formulas.


As I'm using this Dropdownlist as a reference to determine icon colors, I am attempting the following but I humbly request your assistance in forming the formula:

Objective

I have an icon in a Gallery control that displays all Desks in a location.

 

 

Items: Filter('Bookable Desk', 'Bookable Desk (Views)'.'FloorPlan Bookable Desk [Testing]')>

 

 

gymcode_1-1704948858240.png


I would like to display different colors for each Desk, if the Desk Name is found in the Dropdown list below (contains all Desks that have been booked, and their corresponding status).

 

 

ForAll(
    Filter(
        Reservations,
        'Reservations (Views)'.'Active Reservations',
        Date >= FromDate_Dp.Value,
        Date <= ToDate_Dp.Value && ('Status Reason' = 'Status Reason (Reservations)'.Blocked || 'Status Reason' = 'Status Reason (Reservations)'.Booked)
    ),
    {
        DeskName: 'Reserved Desk'.Name,
        StatusReson: 'Status Reason (Reservations)'
    }
)

 

Sudo:

If ThisItem.Name (Gallery Icon) Found In DropDownList above,

    If StatusReason.Value = 'Booked' or 1
        Color = 'Red'
    If StatusReason.Value = ''Blocked or 864630000
        Color = 'Gray'
    Else Color = ''Green


May I request your advice on the formula to be created for 'Color' fx for the Icons?

Thank you.

Hi , @gymcode 

According to your description, you want to change the icon color in Gallery. 
Can you show me your gallery items Table return and the dropdown items table return sample data.

And i am not surely understand about "Found In DropDownList above" , do you mean when we select one of the items in the dropdown control ?

And Your 'Status Reason (Reservations)' column contains one value or more than one value ?

 

And if possible , can you give me some sample data and the end result you want to get ?

 

Best Regards,

Yueyun Zhang

Hi @v-yueyun-msft , thank you for your prompt reply 🙂

Below is my Gallery Items:

Filter('Bookable Desk', 'Bookable Desk (Views)'.'FloorPlan Bookable Desk [Testing]')

 

Allow me to elaborate  "Found In DropDownList above". Below is the formula of the dropdownlist that you assisted me with earlier:

ForAll(
    Filter(
        Reservations,
        'Reservations (Views)'.'Active Reservations',
        Date >= FromDate_Dp.Value,
        Date <= ToDate_Dp.Value && ('Status Reason' = 'Status Reason (Reservations)'.Blocked || 'Status Reason' = 'Status Reason (Reservations)'.Booked)
    ),
    {
        DeskName: 'Reserved Desk'.Name,
        StatusReson: 'Status Reason (Reservations)'
    }
)



With the 2 values 'BookableDesk.Name' and 'Reservation.BookingStatus' available in the Dropdown, I want to check all the Desks in the Gallery, if they are found in the Dropdown 'BookableDesk.Name'.

If it's found, using 'Reservation.BookingStatus' value, set the color for the Seats based on the OptionSet (Booked, Blocked, etc). 

Hi, @gymcode 

I test it in my side , you can use this code to show the Choices column in Dataverse.

 

 

 

ShowColumns(
 AddColumns(
    Filter(
        Reservations,
        'Reservations (Views)'.'Active Reservations',
        Date >= FromDate_Dp.Value,
        Date <= ToDate_Dp.Value && ('Status Reason' = 'Status Reason (Reservations)'.Blocked || 'Status Reason' = 'Status Reason (Reservations)'.Booked)
    ) As Ta, "StatusReson_Text", Text(Ta.InternalCOlumnName),  "DeskName_Text", 'Reserved Desk'.Name ),
"StatusReson_Text","DeskName_Text")

 

 

You need to find your Internal COlumn Name and do not use the Optionset.

vyueyunmsft_0-1704961041666.png

In my side :

vyueyunmsft_1-1704961075164.png

 

ShowColumns(
AddColumns(
Filter(
Reservations,
'Reservations (Views)'.'Active Reservations',
Date >= FromDate_Dp.Value,
Date <= ToDate_Dp.Value && ('Status Reason' = 'Status Reason (Reservations)'.Blocked || 'Status Reason' = 'Status Reason (Reservations)'.Booked)
) As Ta, "StatusReson_Text", Text(Ta.InternalCOlumnName), "DeskName_Text", 'Reserved Desk'.Name ),
"StatusReson_Text","DeskName_Text")

 

Also , you can find the internal columnName here :

vyueyunmsft_2-1704961177749.png

 

 

Best Regards,

Yueyun Zhang

Hi @v-yueyun-msft , thanks for checking on the StatusReason field.

I hope I did not have mistaken your question of
<'Status Reason (Reservations)' column contains one value or more than one value ?>

> This field belongs to "Reservation" entity, and it will contain more than 1 returned value from the formula of the Dropdown list

1) 'Status Reason' ='Status Reason (Reservations)'.Blocked
2) 'Status Reason' = 'Status Reason (Reservations)'.Booked

 

ForAll(
    Filter(
        Reservations,
        'Reservations (Views)'.'Active Reservations',
        Date >= FromDate_Dp.Value,
        Date <= ToDate_Dp.Value && ('Status Reason' = 'Status Reason (Reservations)'.Blocked || 'Status Reason' = 'Status Reason (Reservations)'.Booked)
    ),
    {
        DeskName: 'Reserved Desk'.Name,
        StatusReson: 'Status Reason (Reservations)'
    }
)

 

HI , @gymcode 

Yeah, the code is Optionset in Dataverse, so it will always return all the choices.

'Status Reason (Reservations)'

 So if you want to show each row's status , you can not use this name , you need to use the internal column name .

vyueyunmsft_0-1704961561516.png

 

Best Regards,

Yueyun Zhang

 

Helpful resources

Announcements

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  

Welcome to the Power Apps Community

Welcome! Congratulations on joining the Microsoft Power Apps community! You are now a part of a vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun! Now that you are a member, you can enjoy the following resources:   The Microsoft Power Apps Community Forums If you are looking for support with any part of Microsoft Power Apps, our forums are the place to go. They are titled "Get Help with Microsoft Power Apps " and there you will find thousands of technical professionals with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Apps community forums! Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered!   Microsoft Power Apps IdeasDo you have an idea to improve the Microsoft Power Apps experience, or a feature request for future product updates? Then the "Power Apps Ideas" section is where you can contribute your suggestions and vote for ideas posted by other community members. We constantly look to the most voted Ideas when planning updates, so your suggestions and votes will always make a difference.   Community Blog & NewsOver the years, more than 600 Power Apps Community Blog Articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on building Power Apps. On the Power Apps Community Blog, read the latest Power Apps related posts from our community blog authors around the world. Let us know if you would like to become an author and contribute your own writing — everything Power Apps related is welcome!   Power Apps Samples, Learning and Videos GalleriesOur galleries have a little bit of everything to do with Power Apps. Our galleries are great for finding inspiration for your next app or component. You can view, comment and kudo the apps and component gallery to see what others have created! Or share Power Apps that you have created with other Power Apps enthusiasts. Along with all of that awesome content, there is the Power Apps Community Video & MBAS gallery where you can watch tutorials and demos by Microsoft staff, partners, and community gurus in our community video gallery.   Again, we are excited to welcome you to the Microsoft Power Apps community family! Whether you are brand new to the world of process automation or you are a seasoned Power Apps veteran. Our goal is to shape the community to be your ‘go to’ for support, networking, education, inspiration and encouragement as we enjoy this adventure together!   Let us know in the Community Feedback if you have any questions or comments about your community experience.To learn more about the community and your account be sure to visit our Community Support Area boards to learn more! We look forward to seeing you in the Power Apps Community!The Power Apps Team

Top Solution Authors
Top Kudoed Authors
Users online (5,116)