cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
akosiwong
Level: Powered On

DataTable row count

Hi,

 

How to count the numbers of rows in a DataTable?

 

Thanks,

Gilbert

Thanks,
Gilbert
13 REPLIES 13
Pripri804
Level 8

Re: DataTable row count

CountRows(datasource)
akosiwong
Level: Powered On

Re: DataTable row count

HI,

 

I tried that but is says "Invalid Argument type(control)".

Thanks,
Gilbert
Pripri804
Level 8

Re: DataTable row count

you have to create a label, and in the text field write the formula

Pripri804
Level 8

Re: DataTable row count

can you post a screenshot ?

Super User
Super User

Re: DataTable row count

I suspect you're getting this error because you're passing the data table name to the CountRows function like so:

 

CountRows(DataTable1)

The trick is to provide the data source to the CountRows function, rather than the table name. You can find this by viewing the properties of your data table, and going to the Data section.

akosiwong
Level: Powered On

Re: DataTable row count

Hi,

 

I am using it in an "if" command "if (countrows(datatable2) > 0, navigate(blah), false)"

 

is this wrong?

Thanks,
Gilbert
Super User
Super User

Re: DataTable row count

Hi Gibert,

 

Yes, the value that you need to pass to the countrows function is the datasource, not the datatable.

 

In my example here, the value I would pass to the countrows function is highlighted.

 

datatable1.JPG

So in your case, it would be:

 

"if (countrows(datasource) > 0, navigate(blah), false)"

 

Highlighted
akosiwong
Level: Powered On

Re: DataTable row count

one more question, i put filter on the datatable

 

Filter(ProjectHistory,Title= DataCardValue9.Text)

 

how will i use this?

 

Thanks,
Gilbert
Super User
Super User

Re: DataTable row count

@akosiwong

 

Try this -

 

 

If (Countrows( Filter(ProjectHistory,Title= DataCardValue9.Text) ) > 0, navigate(blah), false)

 

so basically it will count the rows for the filtered datasource .

 

I see that you are just checking if the table is empty of not, so you could also use the IsEmpty function.

 

Hope this helps!

 

 


Vivek Bavishi aka That API Guy
PowerApps and Flow MVP
Blog | Twitter | YouTube | Community Profile | GitHub



If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 67 members 3,050 guests
Please welcome our newest community members: