cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AB1
Post Patron
Post Patron

Assistance Needed with Power App Formula for Calculating Food Order Costs

Hi all

 

I'm currently using two SharePoint lists as data sources for a Power App. The main objective of this Power App is to streamline food orders and display them in a gallery for caterers to monitor live orders. One of the SharePoint lists stores all the orders, initially entered by users through a Power App form, while the other contains a catalog of food options with prices.

In my Power App form, I'm encountering a challenge: I need to create a formula, similar to a VLOOKUP, that can identify the items ordered by individual users and calculate the total cost of their selections. Can you please assist me in developing the formula for this?

The data from the form is then transferred to a SharePoint list dedicated to storing prices. Subsequently, I need to calculate and display the total cost by summing the quantities ordered for each food choice and multiplying them by their respective prices. This total cost should be presented in a gallery alongside the selected items.

 

 

My form on Power app: 

 

Screenshot 2023-09-27 at 15.56.46.png

 

The form then goes into a sharepoint is which is: 

 

Screenshot 2023-09-27 at 19.12.48.png

 

 

 

Stores the prices: 

 

Screenshot 2023-09-27 at 19.13.08.png

The gallery 

 

Screenshot 2023-09-27 at 19.17.01.png

 

I would greatly appreciate your assistance in solving this challenge.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @AB1,

Glad I was able to help! 😊

 

Here we will need the same Text function to format our number value:

Text(
    Sum(
        Filter(
            'Food prices',
            'Food choice' in ThisItem.'Food Option'.Value
        ),
        Price
    ),
    "£#,##0.00"
)

 

If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

Thanks!

View solution in original post

13 REPLIES 13
LaurensM
Super User
Super User

Hi @AB1,

 

In the Form you could e.g. autofill a number column data card or add a new label with the following Text Property (Default for a DataCardValue):

//Note: I expect Food Option to be a LookUp to the Food prices list

//Total sum of Price
Sum(
    //Fetch details of all selected Food prices
    Filter(
        'Food prices',
        //Change DataCardValue to the correct name of the Food Option combobox
        ID in DataCardValue.SelectedItems.Id
    ),
    Price
)

 

In your gallery you would use the code above in the Text property of a label and change DataCardValue.SelectedItems.Id to ThisItem.'Food Option'.Id

Alternatively, you save the total price to a number column when the users saves the form and simply reference that column in the gallery.

 

If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

Thanks!

Hi @LaurensM Thanks for this however this doesn't work out the cost + quantity + items ordered: 

 

Screenshot 2023-09-28 at 08.46.58.png

Doesnt work out anything unless I have put in the formular incorrect: 

 

Screenshot 2023-09-28 at 08.46.52.png

 

The food option detail: 

 

Screenshot 2023-09-28 at 08.46.23.png

 

Any ideas where I am going wrong? 

@AB1,

 

Within the gallery it would be the following formula:

Sum(
    Filter(
        'Food prices',
        ID in ThisItem.'Food Option'.Id
    ),
    Price
)

 

I did not see a 'quantity' column in your list. Should you want the Sum() of prices x quantity use the following structure:

Sum() * ThisItem.QuantityColumn

 

I hope this helps!

AB1
Post Patron
Post Patron

Hi,

 

So the formula: 

 

Screenshot 2023-09-29 at 08.24.18.png

 

I have to put .value as it wasn’t accepting .id 

Food prices is a Sharepoint list containing a column called food choice and price 

 

Tracking is a Sharepoint list which is linked to the gallery

 

 

Screenshot 2023-09-29 at 08.27.01.png

With the formula :

Sum() * ThisItem.'Covers ' 

 

Covers is our quantity, is this formula meant to be in another text box? Or would it be with the formula 

 

Sum(

    Filter(

        'Food prices',

        ID in ThisItem.'Food Option’.Value

    ),

    Price

)

 

Error I am getting when adding in a separate text box

 

: 

Screenshot 2023-09-29 at 08.24.05.png

 

 

 

 

The Food Option as seen in the screenshot of the tracker sharepoint can contain multiple food choices. 

 

Please help!

AB1
Post Patron
Post Patron

Hi @LaurensM Can you assist please ? Appreciate your help

Hi @AB1,

 

First of all, my utmost apologies for the delay in reply! Starting from last week Friday, I had no access to a computer and very limited access to Wi-Fi. 

 

My solution was built on the premise that Food Option was a Look-Up column to the 'Food prices' list. I now notice that Food Option is a Multi-Select Choice field. We will have to adjust the code to check whether the 'Food choice' column matches the .Value of our choice - instead of trying to compare IDs:

Sum(
    Filter(
        'Food prices',
        //'Food choice' refers to the text column containing the food value in the 'Food prices' list
        //Adjust in case the column name is spelled incorrectly
        'Food choice' in ThisItem.'Food Option'.Value
    ),
    Price
)

The Choice value will have to match the Food choice text value fully. (Pay close attention to spaces or capitalization)

 

For the total price, should we calculate the total food value * the value of the Covers column? The following code will achieve this:

Sum(
    Filter(
        'Food prices',
        //'Food choice' refers to the text column containing the food value in the 'Food prices' list
        //Adjust in case the column name is spelled incorrectly
        'Food choice' in ThisItem.'Food Option'.Value
    ),
    Price
) * ThisItem.Covers

 

Important note: Is there a specific reason for using a Multi-Select choice field instead of a Multi-Select Look-Up? With the current set-up you will have to maintain both the Master Data list (Food prices) and a Choice set. In other words, a new row in the Food prices list will not automatically add an option to your 'Food choice' column.

 

I hope this helps!

Hi @LaurensM 

 

Thanks for this! So this worked: 

Sum(
    Filter(
        'Food prices',
        //'Food choice' refers to the text column containing the food value in the 'Food prices' list
        //Adjust in case the column name is spelled incorrectly
        'Food choice' in ThisItem.'Food Option'.Value
    ),
    Price
)

 

But is there a way to get it to show in pounds on the power app? 

 

Screenshot 2023-10-12 at 09.27.20.png

 

This however didnt work: 

Sum(
    Filter(
        'Food prices',
        //'Food choice' refers to the text column containing the food value in the 'Food prices' list
        //Adjust in case the column name is spelled incorrectly
        'Food choice' in ThisItem.'Food Option'.Value
    ),
    Price
) * ThisItem.Covers

 

Error: 

 

Screenshot 2023-10-12 at 09.29.59.png

 

I think this might have do with something do with Covers being in my tracker sharepoint rather than Food prices sharepoint? Is there a way to get around this? 

 

Screenshot 2023-10-12 at 09.23.29.pngScreenshot 2023-10-12 at 09.23.14.png

Appreciate your help!

@AB1,

 

We are getting close! 😊

 

We can style our number value by using the Text() function around our code:

Text(<code>, "£#,##0.00")

 

The Covers is not recognized since it is named with a space at the end in your SP list. (See your last screenshot in the comment of 2 weeks ago). It should be referenced as ThisItem.'Covers ' (I think it is 1 space after the s). I think the column is also mentioned in the Text property of one of your existing labels within the gallery.

 

Our full code would look as follows:

Text(
    Sum(
        Filter(
            'Food prices',
            'Food choice' in ThisItem.'Food Option'.Value
        ),
        Price
    ) * ThisItem.'Covers ',
    "£#,##0.00"
)

 

If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

Thanks!

@LaurensM Thank you!

 

How do I add this in pounds too:

 

Sum(
    Filter(
        'Food prices',
        //'Food choice' refers to the text column containing the food value in the 'Food prices' list
        //Adjust in case the column name is spelled incorrectly
        'Food choice' in ThisItem.'Food Option'.Value
    ),
    Price
)

Helpful resources

Announcements

Tuesday Tip | How to Get Community Support

It's time for another Tuesday Tip, 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.       This Week: All About Community Support Whether you're a seasoned community veteran or just getting started, you may need a bit of help from time to time! If you need to share feedback with the Community Engagement team about the community or are looking for ways we can assist you with user groups, events, or something else, Community Support is the place to start.   Community Support is part of every one of our communities, accessible to all our community members.   Within each community's Community Support page, you'll find three distinct areas, each with a different focus to help you when you need support from us most. Power Apps: https://powerusers.microsoft.com/t5/Community-Support/ct-p/pa_community_support Power Automate: https://powerusers.microsoft.com/t5/Community-Support/ct-p/mpa_community_support Power Pages: https://powerusers.microsoft.com/t5/Community-Support/ct-p/mpp_community_support Copilot Studio: https://powerusers.microsoft.com/t5/Community-Support/ct-p/pva_community-support   Community Support Form If you need more assistance, you can reach out to the Community Team via the Community support form. Choose the type of support you require and fill in the form accordingly. We will respond to you promptly.    Thank you for being an active part of our community. Your contributions make a difference!   Best Regards, The Community Management Team

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  

Tuesday Tip: Community User Groups

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: Community User Groups and YOU Being part of, starting, or leading a User Group can have many great benefits for our community members who want to learn, share, and connect with others who are interested in the Microsoft Power Platform and the low-code revolution.   When you are part of a User Group, you discover amazing connections, learn incredible things, and build your skills. Some User Groups work in the virtual space, but many meet in physical locations, meaning you have several options when it comes to building community with people who are learning and growing together!   Some of the benefits of our Community User Groups are: Network with like-minded peers and product experts, and get in front of potential employers and clients.Learn from industry experts and influencers and make your own solutions more successful.Access exclusive community space, resources, tools, and support from Microsoft.Collaborate on projects, share best practices, and empower each other. These are just a few of the reasons why our community members love their User Groups. Don't wait. Get involved with (or maybe even start) a User Group today--just follow the tips below to get started.For current or new User Group leaders, all the information you need is here: User Group Leader Get Started GuideOnce you've kicked off your User Group, find the resources you need:  Community User Group ExperienceHave questions about our Community User Groups? Let us know! We are here to help you!

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!  

Tuesday Tip: Getting Started with Private Messages & Macros

Welcome to 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!   This Week's Tip: Private Messaging & Macros in Power Apps Community   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!   Our Knowledge Base article about private messaging and macros is the best place to find out more. Check it out today and discover some key tips and tricks when it comes to messages and macros:   Private Messaging: Learn how to enable private messages in your community profile and ensure you’re connected with other community membersMacros Explained: Discover the convenience of macros—prewritten text snippets that save time when posting in forums or sending private messagesCreating Macros: Follow simple steps to create your own macros for efficient communication within the Power Apps CommunityUsage Guide: Understand how to apply macros in posts and private messages, enhancing your interaction with the Community For detailed instructions and more information, visit the full page in your community today:Power Apps: Enabling Private Messaging & How to Use Macros (Power Apps)Power Automate: Enabling Private Messaging & How to Use Macros (Power Automate)  Copilot Studio: Enabling Private Messaging &How to Use Macros (Copilot Studio) Power Pages: Enabling Private Messaging & How to Use Macros (Power Pages)

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