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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / countrows then do some...
Power Apps
Answered

countrows then do something

(0) ShareShare
ReportReport
Posted on by

I'm trying to count the number of rows that have the value  "Open" in a Status field.

if > 1 then

I need to perform and action ?

 

If(CountRows(Filter('[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]',Status = "Open", Status)> 1))

 

Action:

Patch('[dbo].[t_nsc_trackcode_DataEntry_pa]',LookUp( '[dbo].[t_nsc_trackcode_DataEntry_pa]', NSC_Id = Value(txt_NextId.Text)),{
Status:"Closed",
Closed_Date:varDate//Now()
}
)

 

 

 

 

 

Thanks

Dave

Categories:
I have the same question (0)
  • Vijay Tailor Profile Picture
    2,961 on at

    Hi @Anonymous ,

    Yes , it possible to take the action based on control,

    But this is possible by using ONSelect Property like Button, ICON, Toggle, etc.
    See the below reference Screenshot-

    VijayTailor_0-1602793971423.png


    Code - 

    ClearCollect(Coll1,{Value:1});
    Clear(Coll1);
    //Thisis the Code as you need to impliment like that
    If(CountRows(Filter(TestAkshay,Title<>Blank()))>1,Patch(Coll1,Defaults(Coll1),{Value:15}),Notify("No record FOund",NotificationType.Information));

    Thanks,

    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."-Vijay



  • v-yutliu-msft Profile Picture
    on at

    Hi @Anonymous ,

    Do you want to act an action when there's a status field value is open?

    Could you tell me the data type of Status field?

    1)If it is text type, you could set one button's OnSelect like this:

    If(
    CountRows(Filter('[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]',Status = "Open"))> 1,
    Patch('[dbo].[t_nsc_trackcode_DataEntry_pa]',
     LookUp( '[dbo].[t_nsc_trackcode_DataEntry_pa]', NSC_Id = Value(txt_NextId.Text)),
    {
    Status:"Closed",
    Closed_Date:varDate//Now()
    }
    )
    )
     

    Or you could also consider use IsEmpty to justify where's record that meet requirement:

    If(
    !IsEmpty(Filter('[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]',Status = "Open")),
    Patch('[dbo].[t_nsc_trackcode_DataEntry_pa]',
     LookUp( '[dbo].[t_nsc_trackcode_DataEntry_pa]', NSC_Id = Value(txt_NextId.Text)),
    {
    Status:"Closed",
    Closed_Date:varDate//Now()
    }
    )
    )
    

     

    2)If it is choice type, you could set one button's OnSelect like this:

     

    If(
    CountRows(Filter('[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]',Status.Value = "Open"))> 1,
    Patch('[dbo].[t_nsc_trackcode_DataEntry_pa]',
     LookUp( '[dbo].[t_nsc_trackcode_DataEntry_pa]', NSC_Id = Value(txt_NextId.Text)),
    {
    Status:{Value:"Closed"},
    Closed_Date:varDate//Now()
    }
    )
    )
     

     

    Or you could also consider use IsEmpty to justify where's record that meet requirement:

     

    If(
    !IsEmpty(Filter('[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]',Status.Value = "Open")),
    Patch('[dbo].[t_nsc_trackcode_DataEntry_pa]',
     LookUp( '[dbo].[t_nsc_trackcode_DataEntry_pa]', NSC_Id = Value(txt_NextId.Text)),
    {
    Status:{Value:"Closed"},
    Closed_Date:varDate//Now()
    }
    )
    )
    

     

     

     

    Best regards,

     

     

  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    this is what I used..

     

    If(CountRows(
            Filter('[dbo].[t_nsc_trackcode_assigned_DataEntry_pa]',
                Status = "Open",
                ID_Racfid = lbl_Racfid_ms.Text
            )
        )> 1,Set(TheVar,Now());Reset(txt_ReOpenedDate)
    ;

  • v-yutliu-msft Profile Picture
    on at

    Hi @Anonymous ,

    So have you solved your problem?

    If yes, could you mark my answer as solution?

    Thanks!

     

     

    Best regards,

    Phoebe

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard