cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
akosiwong
Regular Visitor

DataTable row count

Hi,

 

How to count the numbers of rows in a DataTable?

 

Thanks,

Gilbert

Thanks,
Gilbert
18 REPLIES 18
Pripri804
Advocate III
Advocate III

CountRows(datasource)

HI,

 

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

Thanks,
Gilbert

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

can you post a screenshot ?

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
Regular Visitor

Hi,

 

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

 

is this wrong?

Thanks,
Gilbert

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

 

akosiwong
Regular Visitor

one more question, i put filter on the datatable

 

Filter(ProjectHistory,Title= DataCardValue9.Text)

 

how will i use this?

 

Thanks,
Gilbert

@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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (2,497)