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

countrows then do something

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

1 ACCEPTED SOLUTION

Accepted Solutions

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)
;

View solution in original post

4 REPLIES 4
Resident Rockstar
Resident Rockstar

Hi @DAVIDPOWELL ,

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



Community Support
Community Support

Hi @DAVIDPOWELL ,

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,

 

 

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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)
;

View solution in original post

Hi @DAVIDPOWELL ,

So have you solved your problem?

If yes, could you mark my answer as solution?

Thanks!

 

 

Best regards,

Phoebe

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (9,973)