Count Number of Rows from Other View

App has one view with a list of vehicles. My ultimate goal is to display a percentage in a pie chart of number of vehicles that need oil changes and another for inspections.

When I tried to use a virtual column with Count(Car Table[_RowNumber]) it returned the correct number BUT it was in each row. I just need the number of rows once, not recorded so many times.

My thought process was to create a second view with one row. One column with total cars, one column with total cars that need oil changes, and the last is the percentage of vehicles that need oil changes.

But when I try to Count(Car Table[_RowNumber]) from the 2nd view it comes up blank not returning anything. 

Is my thinking wrong? I am newer to appsheet.

Thanks

0 7 142
7 REPLIES 7

If you could let us know how your data is arranged in the Car Table, meaning is there a column that identifies cars needing oil change and any other status , we could possibly evaluate a way to plot the desired graph. 

One column for "Vehicle Registration" and one for "Insp Exp Date."

I have a Slice to display vehicles needing inspection with the formula:

[Insp Exp Date] < Now() + 30 = True

Not sure if that's important but that's where I'm at. 

Thank you. I meant you wanted to display in chart cars needing oil change vs total cars. So could you add where you are capturing this status. I think your first post ( chart about oil change needing vehicle %) and second post ( inspection exp dates ) have two different set of information.

You may want to restate exactly where you are looking for help.

I need it for both scenarios. But I will focus on one. 

I need to count the total cars, and total cars that need inspections, then get a percentage.

My issue is when I use a virtual column to count the number of Rows(Cars) on Car Table, it returns the total cars in every row. So lets say there's ten total cars, the number 10 is in every row of the virtual column. I just need it once. 

Sorry if I am not explaining myself effectively.

That is the nature of virtual columns by default. When you say you want it only once, but you may want to finalize in which row out of those 10 rows., you want that result This is so because once you decide to restrict it to one row, you will need to reference that row for any further use of that number. Also in general using multi row expressions such as SELECT() in virtual columns is not a good practice for large tables as it can slow the app's sync performance.

Also if you do not need that number in any further calculations but just for display purpose, then  you could simply use group by option in views that can give you the desired grouping.

Control grouping - AppSheet Help

 

How would I restrict it to one row? What would that look like?

Or could I simply count the numbers of Rows in Car List from a different view called perhaps "Stats"

 

Thank you for your help so far.

In general it could be something like 

IF([_ROWNUMBER]=2,  Count(Car Table[_RowNumber]), "")

This will show the count only in row number 2 and blank in that column in other rows. But please be aware that the virtual column will be available in all rows. You cannot selectively have VC appearing only in some rows. Of course you may hide it with show_if but it will be there.

Top Labels in this Space