cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lubu97
Regular Visitor

Summation between 2 Dates and their values

I have table in Excel and i want my app in power apps to let the user Select (2-Dates) (From and to), and then to show the summation between both of these 2 values as you can see below:

 

Excel.PNG

 

For example i want to chose From Date (23-Nov) to Date (29-Nov) and then it shows me the summation between these values, as it should show (344,237). I really appreciate your quick support with this problem guys, i really tried all the possible solutions on the internet but it didn't work.

1 ACCEPTED SOLUTION

Accepted Solutions
cha_cha
Resident Rockstar
Resident Rockstar

Hello @Lubu97 

 

Just to be clear, I was just giving you advice that I would have given myself when I was starting with PowerApps. If you actually search here in the forum, there are so many bugs/issues related to using Excel as data storage. Also as someone who supports the community, we'd love for everyone to be able to fully enjoy the capabilities of the platform instead of spending time and pulling hairs just to figure out why a simple function is not working.

 

Following @WarrenBelz solution, this would be my recommended solution:

Sum(
    Filter(Games, 
        ThisRecord.Dates >= StartDropDown.Selected.Dates,
        ThisRecord.Dates <= EndDropDown.Selected.Dates),
       IfError(Numbers,0)
)

 

I have recorded a short video explaining. Not hating excel but just happen to mention it many times. So just ignore it.

https://youtu.be/Acxd7H44Xl0

 

I followed your screenshot as Data Source. Disregard the PowerAppsID column. 

cha_cha_0-1670229970129.png

 

AABC.gif

 

I did try creating a new table with numbers with commas in it. so far works fine on my end. Crossing my fingers and hoping it works on your end. Added the Text Function to add commas  to the result.

cha_cha_1-1670230744563.png

Text(Sum(
    Filter(Games, 
        ThisRecord.Dates >= StartDropDown_1.Selected.Dates,
        ThisRecord.Dates <= EndDropDown_1.Selected.Dates),
       IfError(Numbers,0)
),"##,###")

DEF.gif

 


  ✔️
Just in case my response helped you solve your problem, please mark/accept this as a SOLUTION This helps community members if they experience a similar issue in the future.

 

  🔗
🕸bistek.space  🐦 @cha_bistek  📺 @BisTekSpace 

 


 
Just in case you my answer helped you solve your problem, please mark/accept this as a SOLUTION This helps community members if they experience a similar issue in the future.

 
bistek.space   @cha_bistek    @BisTekSpace 

View solution in original post

19 REPLIES 19
cha_cha
Resident Rockstar
Resident Rockstar

Hello @Lubu97 

 

First, please change your Data Source to something like SharePoint (Free) or Dataverse. We will have issues with date formatting and adding number if you keep on using Excel.

Here's a full detailed explanation of why Excel is a bad data source.

https://www.youtube.com/watch?v=RtmZM3tm2Zs

 

Second, kindly please send screenshots of how your App form looks like when you select two data so we/I can suggest code that would solve your issue.

 


 
Just in case you my answer helped you solve your problem, please mark/accept this as a SOLUTION This helps community members if they experience a similar issue in the future.

 
bistek.space   @cha_bistek    @BisTekSpace 
WarrenBelz
Super User
Super User

@Lubu97 ,

I totally agree with @cha_cha that Excel is a far from ideal data source and you will have more issues than date formats if you continue to use it (SharePoint is far better and is a standard licence). Also, Count is a bad name for a field. This is not Delegable (so it will not work for records numbers over your (500-2,000) Delegation limit), but should give you the total.

Sum(
   Filter(
      AddColumns(
         YourExcelTable,
         "MyDate"
         DateValue(Datee),
      ),
      MyDate >= YourFromDP.SelectedDate &&
      MyDate <= YourToDP.SelectedDate
   ),
   Count
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Hello Cha_Cha,

We are using Excel in our organization so we can share it between us by one drive and keep it updated, Also its well known application.

Below is screen shot of my program, i tried to use dropdown to select the Date (From) and (to) and text input to display the total summation, but i tried so many ways in the internet but it didn't work for me

 

Capture.PNG

Also, i tried to use DatePicker but i couldnt know how to link it to my excel sheet table.

I really appreciate your support to help me with this issue.

 

Thanks

Best Regards

Hello  @WarrenBelz,

I changed the name of the column (Count) to (Counte), Also we are using excel in our organization because its simple and easy to use. 

 

Capture.PNG

 iam trying to use the dropdown to selcet the Date and textinput to show the date of that specified date, but iam trying to get the total of between these 2 Dates.

 

I really appreciate your support with helping me with this issue.

Regards 

@Lubu97 

I now see you do not have Date Pickers, but drop-downs, so this makes it even more complex as you need to also convert those (which are Text in the drop-down) to a date and time. All of the below depends on you having both the Excel field and the drop-down Items in a valid format to be converted to Date/Time.

Sum(
   Filter(
      AddColumns(
         YourExcelTable,
         "MyDate"
         DateTimeValue(Datee)
      ),
      MyDate >= DateTimeValue(YourFromDD.Selected.Value) &&
      MyDate <= DateTimeValue(YourToDD.Selected.Value)
   ),
   Counte
)

Excel might be easy for you to use, but you need to realise certain things just do not work the way they do (easily and consistently) in SharePoint - dates are a prime example. Also, when an Excel file is used as a Data Source for Power Apps, you cannot have it open in Excel and all changes to the data need to be made in Power Apps, so it sort of defeats the purpose of using it if you have access to SharePoint.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Dear Warren,

What if i use the DatePicker if its gonna make it simpler, then why not, but i didnt know how to cennect the datepicker to my table in the excel.

Also where should i put that code you sent me, should i put it in the (textinput)? also what should i change in it except the name of the table?

 

Regards

@Lubu97 ,

It will produce a numeric value, so the Text of a Label would show it. If you are going to use time as well, you will need hour/minute drop-downs in addition to the Date Pickers, so stick with what you have as you need to convert Text to Dates on both sides. Date Pickers are good for SharePoint as the List field is stored as a Date, requiring no conversion. As well as the Table name, you will also need the name of your drop-downs.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Dear, 

Below are the error messages i get from putting the code you sent me on the (Textinput):

 

Screenshot 2022-12-04 150611.png

Capture1.PNG

  

Also, Should i make the format of the dates in my excel (General) or keep it as short date ?

 

Regards

 

Dear @WarrenBelz,

I Just need the date to be displayed as (MM,DD,YYYY), no need for time.

Regards

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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