cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sheharyarhamid
Frequent Visitor

Getting another 6 comparsion error

Hello everyone i m getting these 6 errors actually the six errors are same.

This is the excel formula in which i m getting error its a built in template app of power app.The Budget Tracker App.

This is the excel formula as shown in pictures below this code.

 

If(IsBlank(LookUp(ExpenseByCategory, BudgetId=Gallery1.Selected.BudgetId && Category = FormNewExpense.LastSubmit.Category).ID),Patch(ExpenseByCategory,Defaults(ExpenseByCategory),{ID:Max(ExpenseByCategory,ID)+1,Category:FormNewExpense.LastSubmit.Category,Expense:FormNewExpense.LastSubmit.Expense,BudgetId:Gallery1.Selected.BudgetId}),Patch(ExpenseByCategory,LookUp(ExpenseByCategory, BudgetId = Gallery1.Selected.BudgetId && Category =FormNewExpense.LastSubmit.Category), {Expense:Value(LookUp(ExpenseByCategory, BudgetId = Gallery1.Selected.BudgetId && Category = FormNewExpense.LastSubmit.Category).Expense) + Value(FormNewExpense.LastSubmit.Expense)}));
If(CountRows(ReceiptsCollect)>=1,UpdateContext({ReceiptRecord:Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,1)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(CountRows(ReceiptsCollect)>=2,UpdateContext({ReceiptRecord:Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,2)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Value(Id) = Max(Expenses,Id),ExpenseName)})}));
If(CountRows(ReceiptsCollect)>=3,UpdateContext({ReceiptRecord:Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,3)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(CountRows(ReceiptsCollect)>=4,UpdateContext({ReceiptRecord:Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,4)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(CountRows(ReceiptsCollect)>=5,UpdateContext({ReceiptRecord:Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,5)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(CountRows(ReceiptsCollect)>=6,UpdateContext({ReceiptRecord:Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,6)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(CountRows(ReceiptsCollect)=7,UpdateContext({ReceiptRecord:Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,7)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
Navigate(BudgetScreen,ScreenTransition.Fade);ResetForm(FormNewExpense)

 

Screenshot (57).png

 

Screenshot (59).png

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@sheharyarhamid 

I don't know what your datasource is for this, but I am assuming from some hints that it is an Excel file.

I would have a look at your formula in your conditions for >=1, >=3, >=4, >=5, >=6, and =7.

In those places you have a ReceiptName that is populated by a Lookup.  There are exactly 6 instances of this where you compare Id = Max(Expenses... however, in >=2 condition, you specifically cast Id with Value(Id).  

Again, not knowing your datasource, it's possible that you need to provide the Value(Id) for all of your other conditions.

 

You might want to consider as well using a ForAll function with your ReceiptsCollect to perform those patches - that way you have only one Patch formula to deal with and not 7.

Something like this:

ForAll(ReceiptsCollect,
  Patch(Receipts,
           Defaults(Receipts),
           {Receiptlist: ReceiptImage,
            Id: Max(Receipts,Id) + 1, 
            BudgetId: Gallery1.Selected.BudgetId, 
            ExpenseId: Max(Expenses,Id), 
            ReceiptName: LookUp(Expenses, Value(Id) = Max(Expenses,Id),ExpenseName)
            }
           )
    )

There may be adjustments needed for your specific datasource and what you are working with, but the idea is the same.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

6 REPLIES 6
yashag2255
Dual Super User II
Dual Super User II

Hi @sheharyarhamid , 

 

The error you are getting is because of the comparison between the type text and a number.
Try this below code and please let me know if you still see the same issues:
 
If(IsBlank(LookUp(ExpenseByCategory, BudgetId=Gallery1.Selected.BudgetId && Category = FormNewExpense.LastSubmit.Category).ID),Patch(ExpenseByCategory,Defaults(ExpenseByCategory),{ID:Max(ExpenseByCategory,ID)+1,Category:FormNewExpense.LastSubmit.Category,Expense:FormNewExpense.LastSubmit.Expense,BudgetId:Gallery1.Selected.BudgetId}),Patch(ExpenseByCategory,LookUp(ExpenseByCategory, BudgetId = Gallery1.Selected.BudgetId && Category =FormNewExpense.LastSubmit.Category), {Expense:Value(LookUp(ExpenseByCategory, BudgetId = Gallery1.Selected.BudgetId && Category = FormNewExpense.LastSubmit.Category).Expense) + Value(FormNewExpense.LastSubmit.Expense)}));
If(Value(CountRows(ReceiptsCollect))>=1,UpdateContext({ReceiptRecordSmiley: Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,1)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(Value(CountRows(ReceiptsCollect))>=2,UpdateContext({ReceiptRecordSmiley: Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,2)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Value(Id) = Max(Expenses,Id),ExpenseName)})}));
If(Value(CountRows(ReceiptsCollect))>=3,UpdateContext({ReceiptRecordSmiley; Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,3)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(Value(CountRows(ReceiptsCollect))>=4,UpdateContext({ReceiptRecordSmiley: Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,4)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(Value(CountRows(ReceiptsCollect))>=5,UpdateContext({ReceiptRecordSmiley: Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,5)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(Value(CountRows(ReceiptsCollect))>=6,UpdateContext({ReceiptRecordSmiley: Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,6)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(Value(CountRows(ReceiptsCollect))=7,UpdateContext({ReceiptRecordSmiley: Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,7)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
Navigate(BudgetScreen,ScreenTransition.Fade);ResetForm(FormNewExpense)
Navigate(BudgetScreen,ScreenTransition.Fade);ResetForm(FormNewExpense)
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
RandyHayes
Super User
Super User

@sheharyarhamid 

I don't know what your datasource is for this, but I am assuming from some hints that it is an Excel file.

I would have a look at your formula in your conditions for >=1, >=3, >=4, >=5, >=6, and =7.

In those places you have a ReceiptName that is populated by a Lookup.  There are exactly 6 instances of this where you compare Id = Max(Expenses... however, in >=2 condition, you specifically cast Id with Value(Id).  

Again, not knowing your datasource, it's possible that you need to provide the Value(Id) for all of your other conditions.

 

You might want to consider as well using a ForAll function with your ReceiptsCollect to perform those patches - that way you have only one Patch formula to deal with and not 7.

Something like this:

ForAll(ReceiptsCollect,
  Patch(Receipts,
           Defaults(Receipts),
           {Receiptlist: ReceiptImage,
            Id: Max(Receipts,Id) + 1, 
            BudgetId: Gallery1.Selected.BudgetId, 
            ExpenseId: Max(Expenses,Id), 
            ReceiptName: LookUp(Expenses, Value(Id) = Max(Expenses,Id),ExpenseName)
            }
           )
    )

There may be adjustments needed for your specific datasource and what you are working with, but the idea is the same.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

I have tried your formula previously 1 have six error all same but now i m getting 9 errorsScreenshot (60).png

 

Screenshot (61).png

 

Hi @sheharyarhamid 

 

Can you confirm the data source connection are you using with your app? I tried to create one directly from the template with a connection to One drive for business and I don't see any errors with the default code. So, I am guessing that the issue might be because of improper connection that the datasource. 
 
Can you try loging out of the current session, close browser and login again + delete the existing connection to the data source and create a new one. 
 
Screenshot: MicrosoftTeams-image (56).png

 

Expression: 
 
Spoiler
If(IsBlank(LookUp(ExpenseByCategory, BudgetId=Gallery1.Selected.BudgetId && Category = FormNewExpense.LastSubmit.Category).ID),Patch(ExpenseByCategory,Defaults(ExpenseByCategory),{ID:Max(ExpenseByCategory,ID)+1,Category:FormNewExpense.LastSubmit.Category,Expense:FormNewExpense.LastSubmit.Expense,BudgetId:Gallery1.Selected.BudgetId}),Patch(ExpenseByCategory,LookUp(ExpenseByCategory, BudgetId = Gallery1.Selected.BudgetId && Category =FormNewExpense.LastSubmit.Category), {Expense:Value(LookUp(ExpenseByCategory, BudgetId = Gallery1.Selected.BudgetId && Category = FormNewExpense.LastSubmit.Category).Expense) + Value(FormNewExpense.LastSubmit.Expense)}));
If(CountRows(ReceiptsCollect)>=1,UpdateContext({ReceiptRecord:Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,1)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(CountRows(ReceiptsCollect)>=2,UpdateContext({ReceiptRecord:Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,2)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(CountRows(ReceiptsCollect)>=3,UpdateContext({ReceiptRecord:Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,3)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(CountRows(ReceiptsCollect)>=4,UpdateContext({ReceiptRecord:Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,4)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(CountRows(ReceiptsCollect)>=5,UpdateContext({ReceiptRecord:Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,5)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(CountRows(ReceiptsCollect)>=6,UpdateContext({ReceiptRecord:Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,6)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
If(CountRows(ReceiptsCollect)=7,UpdateContext({ReceiptRecord:Patch(Receipts,Defaults(Receipts),{Receiptlist:Last(FirstN(ReceiptsCollect,7)).ReceiptImage,Id:Max(Receipts,Id) + 1, BudgetId:Gallery1.Selected.BudgetId, ExpenseId:Max(Expenses,Id), ReceiptName:LookUp(Expenses,Id = Max(Expenses,Id),ExpenseName)})}));
Navigate(BudgetScreen,ScreenTransition.Fade);ResetForm(FormNewExpense)
Hope thsi Helps!
 
 

I get the answer i have solved that issue but there is only 1 problem i mean 1 error is coming.

If ou please kindly help me to solve this last issue

Screenshot (63).png

@sheharyarhamid

I'm still assuming that you're working with an Excel file as your datasource. 

It appears that your form thinks that (from somewhere along the line of your design) that BudgetAmount is a number whereas the datasource thinks it is a string.

Can you confirm that this is Excel you're working with?  If so, then check your formats on the BudgetAmount column and see if it is set to numeric or general or text or some other type.

If it is numeric (or you change it to numeric), I would delete the data source from your app, then add it back in.  Then go to your form and re-add that column.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

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