web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How do I integrate for...
Power Apps
Answered

How do I integrate formula in to existing

(0) ShareShare
ReportReport
Posted on by Super User 2024 Season 1

Hi

 

I would to integrate a formula in to my existing formula below are the formula the first code is the new formula and bottom is the my existing formula please 

 

 

New formula 

 

 

If(
 var,
 Enity1,
 FirstN(Enity1,6)
)

 

 

 

Existing formula

 

 

 

Sort(
AddColumns(
GroupBy(
AddColumns(
If(
FilterGalStatus_2.Selected.Value <> "All" && !IsBlank(searchQuery1),/*Case1*/
Filter(
colChecks,
Status.Value = FilterGalStatus_2.Selected.Value || searchQuery1 in amount || searchQuery1 in Invoice_x0020_Number || searchQuery1 in Date_x0020_due || searchQuery1 in Business_x0020_Name || searchQuery1 in Month_x0020_and_x0020_Year
),
FilterGalStatus_2.Selected.Value = "All" && !IsBlank(searchQuery1),/*Case2*/
Filter(
colChecks,
searchQuery1 in Status.Value || searchQuery1 in Invoice_x0020_Number || searchQuery1 in amount || searchQuery1 in Business_x0020_Name || searchQuery1 in Month_x0020_and_x0020_Year
),
FilterGalStatus_2.Selected.Value = "All" && IsBlank(searchQuery1),/*Case3*/
colChecks,
FilterGalStatus_2.Selected.Value <> "All" && IsBlank(searchQuery1),/*Case4*/
Filter(
colChecks,
FilterGalStatus_2.Selected.Value
)
),
"Comppanyvalue",
Business_x0020_Name
),
"Comppanyvalue",
"NewGroup"
),
"Status",
First(
Sort(
NewGroup,
Status.Value,
Descending
)
).Status.Value,
"Comments",
First(
Sort(
NewGroup,
Note,
Descending
)
).note,
"Modified",
First(
Sort(
NewGroup,
Modified,
Descending
)
).Modified,
"PhoneNum",
First(
Sort(
NewGroup,
Title,
Descending
).Title
),
"Collect",
First(
Sort(
NewGroup,
Month_x0020_and_x0020_Year,
Descending
).Month_x0020_and_x0020_Year
),
"CHECKDUE",
First(
Sort(
NewGroup,
Date_x0020_due,
Descending
)
).Date_x0020_due,
"Pending Invoices",
CountRows(NewGroup),
"Invoice",
First(
Sort(
NewGroup,
Invoice_x0020_Number,
Descending
)
).Invoice_x0020_Number,
"TotalBalance",
Sum(
NewGroup,
amount
),
"SumShippingFee",
Sum(
NewGroup,
amount
),
"InvoiceCreated",
First(
Sort(
NewGroup,
Created,
Descending
)
).Created
),
CHECKDUE,
Descending
)

 

 

Thank you 

Categories:
I have the same question (0)
  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Ramole :

    Could you tell me:

    • Does the Existing formula work properly?

    If it works, I think you can directly replace "Enity1" with your formula.
    The point is, because there is no behavior formula in your formula, you can directly use it as a data source:

     

    If(
     var,
     Sort(
     AddColumns(
     GroupBy(
     AddColumns(
     If(FilterGalStatus_2.Selected.Value <> "All" && !IsBlank(searchQuery1),/*Case1*/
     Filter(colChecks,Status.Value = FilterGalStatus_2.Selected.Value || searchQuery1 in amount || searchQuery1 in Invoice_x0020_Number || searchQuery1 in Date_x0020_due || searchQuery1 in Business_x0020_Name || searchQuery1 in Month_x0020_and_x0020_Year),
     FilterGalStatus_2.Selected.Value = "All" && !IsBlank(searchQuery1),/*Case2*/
     Filter(colChecks,searchQuery1 in Status.Value || searchQuery1 in Invoice_x0020_Number || searchQuery1 in amount || searchQuery1 in Business_x0020_Name || searchQuery1 in Month_x0020_and_x0020_Year),
     FilterGalStatus_2.Selected.Value = "All" && IsBlank(searchQuery1),/*Case3*/
     colChecks,
     FilterGalStatus_2.Selected.Value <> "All" && IsBlank(searchQuery1),/*Case4*/
     Filter(colChecks,FilterGalStatus_2.Selected.Value)),
     "Comppanyvalue",
     Business_x0020_Name
     ),
     "Comppanyvalue",
     "NewGroup"),
     "Status",
     First(Sort(NewGroup,Status.Value,Descending)).Status.Value,
     "Comments",
     First(Sort(NewGroup,Note,Descending)).note,
     "Modified",
     First(Sort(NewGroup,Modified,Descending)).Modified,
     "PhoneNum",
     First(Sort(NewGroup,Title,Descending).Title),
     "Collect",
     First(Sort(NewGroup,Month_x0020_and_x0020_Year,Descending).Month_x0020_and_x0020_Year),
     "CHECKDUE",
     First(Sort(NewGroup,Date_x0020_due,Descending)).Date_x0020_due,
     "Pending Invoices",CountRows(NewGroup),
     "Invoice",First(Sort(NewGroup,Invoice_x0020_Number,Descending)).Invoice_x0020_Number,
     "TotalBalance",Sum(NewGroup,amount),
     "SumShippingFee",Sum(NewGroup,amount),
     "InvoiceCreated",First(Sort(NewGroup,Created,Descending)).Created),
     CHECKDUE,
     Descending
     ),
     FirstN(
     Sort(
     AddColumns(
     GroupBy(
     AddColumns(
     If(FilterGalStatus_2.Selected.Value <> "All" && !IsBlank(searchQuery1),/*Case1*/
     Filter(colChecks,Status.Value = FilterGalStatus_2.Selected.Value || searchQuery1 in amount || searchQuery1 in Invoice_x0020_Number || searchQuery1 in Date_x0020_due || searchQuery1 in Business_x0020_Name || searchQuery1 in Month_x0020_and_x0020_Year),
     FilterGalStatus_2.Selected.Value = "All" && !IsBlank(searchQuery1),/*Case2*/
     Filter(colChecks,searchQuery1 in Status.Value || searchQuery1 in Invoice_x0020_Number || searchQuery1 in amount || searchQuery1 in Business_x0020_Name || searchQuery1 in Month_x0020_and_x0020_Year),
     FilterGalStatus_2.Selected.Value = "All" && IsBlank(searchQuery1),/*Case3*/
     colChecks,
     FilterGalStatus_2.Selected.Value <> "All" && IsBlank(searchQuery1),/*Case4*/
     Filter(colChecks,FilterGalStatus_2.Selected.Value)),
     "Comppanyvalue",
     Business_x0020_Name
     ),
     "Comppanyvalue",
     "NewGroup"),
     "Status",
     First(Sort(NewGroup,Status.Value,Descending)).Status.Value,
     "Comments",
     First(Sort(NewGroup,Note,Descending)).note,
     "Modified",
     First(Sort(NewGroup,Modified,Descending)).Modified,
     "PhoneNum",
     First(Sort(NewGroup,Title,Descending).Title),
     "Collect",
     First(Sort(NewGroup,Month_x0020_and_x0020_Year,Descending).Month_x0020_and_x0020_Year),
     "CHECKDUE",
     First(Sort(NewGroup,Date_x0020_due,Descending)).Date_x0020_due,
     "Pending Invoices",CountRows(NewGroup),
     "Invoice",First(Sort(NewGroup,Invoice_x0020_Number,Descending)).Invoice_x0020_Number,
     "TotalBalance",Sum(NewGroup,amount),
     "SumShippingFee",Sum(NewGroup,amount),
     "InvoiceCreated",First(Sort(NewGroup,Created,Descending)).Created),
     CHECKDUE,
     Descending
     ),
     6)
    )
    
    
    

     

    Best Regards,

    Bof

  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi @v-bofeng-msft 

     

    Yes my Existing formula works and i did try but did not work for me below formula i dont know why 

    If(
     var,
     Sort(
     AddColumns(
     GroupBy(
     AddColumns(
     If(FilterGalStatus_2.Selected.Value <> "All" && !IsBlank(searchQuery1),/*Case1*/
     Filter(colChecks,Status.Value = FilterGalStatus_2.Selected.Value || searchQuery1 in amount || searchQuery1 in Invoice_x0020_Number || searchQuery1 in Date_x0020_due || searchQuery1 in Business_x0020_Name || searchQuery1 in Month_x0020_and_x0020_Year),
     FilterGalStatus_2.Selected.Value = "All" && !IsBlank(searchQuery1),/*Case2*/
     Filter(colChecks,searchQuery1 in Status.Value || searchQuery1 in Invoice_x0020_Number || searchQuery1 in amount || searchQuery1 in Business_x0020_Name || searchQuery1 in Month_x0020_and_x0020_Year),
     FilterGalStatus_2.Selected.Value = "All" && IsBlank(searchQuery1),/*Case3*/
     colChecks,
     FilterGalStatus_2.Selected.Value <> "All" && IsBlank(searchQuery1),/*Case4*/
     Filter(colChecks,FilterGalStatus_2.Selected.Value)),
     "Comppanyvalue",
     Business_x0020_Name
     ),
     "Comppanyvalue",
     "NewGroup"),
     "Status",
     First(Sort(NewGroup,Status.Value,Descending)).Status.Value,
     "Comments",
     First(Sort(NewGroup,Note,Descending)).note,
     "Modified",
     First(Sort(NewGroup,Modified,Descending)).Modified,
     "PhoneNum",
     First(Sort(NewGroup,Title,Descending).Title),
     "Collect",
     First(Sort(NewGroup,Month_x0020_and_x0020_Year,Descending).Month_x0020_and_x0020_Year),
     "CHECKDUE",
     First(Sort(NewGroup,Date_x0020_due,Descending)).Date_x0020_due,
     "Pending Invoices",CountRows(NewGroup),
     "Invoice",First(Sort(NewGroup,Invoice_x0020_Number,Descending)).Invoice_x0020_Number,
     "TotalBalance",Sum(NewGroup,amount),
     "SumShippingFee",Sum(NewGroup,amount),
     "InvoiceCreated",First(Sort(NewGroup,Created,Descending)).Created),
     CHECKDUE,
     Descending
     ),
     FirstN(
     Sort(
     AddColumns(
     GroupBy(
     AddColumns(
     If(FilterGalStatus_2.Selected.Value <> "All" && !IsBlank(searchQuery1),/*Case1*/
     Filter(colChecks,Status.Value = FilterGalStatus_2.Selected.Value || searchQuery1 in amount || searchQuery1 in Invoice_x0020_Number || searchQuery1 in Date_x0020_due || searchQuery1 in Business_x0020_Name || searchQuery1 in Month_x0020_and_x0020_Year),
     FilterGalStatus_2.Selected.Value = "All" && !IsBlank(searchQuery1),/*Case2*/
     Filter(colChecks,searchQuery1 in Status.Value || searchQuery1 in Invoice_x0020_Number || searchQuery1 in amount || searchQuery1 in Business_x0020_Name || searchQuery1 in Month_x0020_and_x0020_Year),
     FilterGalStatus_2.Selected.Value = "All" && IsBlank(searchQuery1),/*Case3*/
     colChecks,
     FilterGalStatus_2.Selected.Value <> "All" && IsBlank(searchQuery1),/*Case4*/
     Filter(colChecks,FilterGalStatus_2.Selected.Value)),
     "Comppanyvalue",
     Business_x0020_Name
     ),
     "Comppanyvalue",
     "NewGroup"),
     "Status",
     First(Sort(NewGroup,Status.Value,Descending)).Status.Value,
     "Comments",
     First(Sort(NewGroup,Note,Descending)).note,
     "Modified",
     First(Sort(NewGroup,Modified,Descending)).Modified,
     "PhoneNum",
     First(Sort(NewGroup,Title,Descending).Title),
     "Collect",
     First(Sort(NewGroup,Month_x0020_and_x0020_Year,Descending).Month_x0020_and_x0020_Year),
     "CHECKDUE",
     First(Sort(NewGroup,Date_x0020_due,Descending)).Date_x0020_due,
     "Pending Invoices",CountRows(NewGroup),
     "Invoice",First(Sort(NewGroup,Invoice_x0020_Number,Descending)).Invoice_x0020_Number,
     "TotalBalance",Sum(NewGroup,amount),
     "SumShippingFee",Sum(NewGroup,amount),
     "InvoiceCreated",First(Sort(NewGroup,Created,Descending)).Created),
     CHECKDUE,
     Descending
     ),
     6)
    )

     

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Ramole :

    Did you set the variable "var"?How is it set up?

    Because I cannot fully replicate your situation, I can only judge it logically.

    The worst plan is to save the result of your original formula to a collection, and then use this collection to replace "Entity1".

    Best Regards,

    Bof

  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi @v-bofeng-msft 

     

     

    UpdateContext({var:!var})

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Ramole :

    The variables set by UpdateContext can only be used on the current screen.

    Have you crossed the screens or used a component?

    If so,I suggest you use 

     

    Set(var,!var)

     

    instead of 

     

    UpdateContext({var:!var})

     

    Best Regards,

    Bof

     

  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi @v-bofeng-msft 

     

    Still same no luck even after 

    Set(var,!var)

     

    Thanks  

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Ramole :

    Could you tell me:

    • Whether the current problem an error or a blank display?What the error is?

    I deleted part of the code to make it look clearer.

    If(
     var,
     Sort(
     AddColumns(
     GroupBy(
     AddColumns(
     colChecks,
     "Comppanyvalue",
     Business_x0020_Name
     ),
     "Comppanyvalue",
     "NewGroup"),
     "CHECKDUE",
     First(Sort(NewGroup,Date_x0020_due,Descending)).Date_x0020_due),
     CHECKDUE,
     Descending
     ),
     FirstN(
     Sort(
     AddColumns(
     GroupBy(
     AddColumns(
     colChecks,
     "Comppanyvalue",
     Business_x0020_Name
     ),
     "Comppanyvalue",
     "NewGroup"),
     "CHECKDUE",
     First(Sort(NewGroup,Date_x0020_due,Descending)).Date_x0020_due),
     CHECKDUE,
     Descending),
     6)
    )

    Or

    If(
     var,
     colChecks,
     FirstN(colChecks,6)
    )

    If it still doesn't work, then I guess something else must be wrong. Please show me the detailed settings of the entire app.

    In addition, I suggest that you consider the method I mentioned before to save data in the collection.

    Best Regards,

    Bof

     

  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    Hi @v-bofeng-msft 

     

    Sorted now, the reason the error was missing FirstN(  second formula copy, all ok now including my existing formula 

     

     

    FirstN(

     

     

     

     

    Thank you so much 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 345 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 177

Last 30 days Overall leaderboard