Just a thought, but try going through the formula and make sure all the quotes are straight quotes and not any smart quotes. This can sometimes mess up formulas in strange ways.
This will total the Time field in the Trips database. I have used all brackets as quote characters so the forum doesn’t convert any to smart quotes. You should add the parameters even though they are empty so Panorama knows what value belongs where. Don’t enclose the aggregate( function in parenthesis if you are using it alone.
It seems to be working regardless of whether I have any particular records selected in either of the databases, but it does not work if I summarize them. Is this correct?
Could the above formula be tweaked to make the calculation for just selected records, for example the month of January for both Expenses and Trips?
If not, how can the formula be changed to achieve that calculation?
The aggregate function works on the selected records, and the query parameter further limits the records that are aggregated. If you want to include all records in the aggregation regardless of the state of the selection in the data sheet, set the fifth parameter to true.
Well, it is just a matter of adding more conditions to your query formula as Kurt suggests. You can check for the two conditions you mention: no summary records and only records for a selected month. For this discussion let’s assume you have the desired month in the variable named theMonth. You can use the monthvalue( function to narrow it down to that month and you can use the info(“summary”) function to include only data records (no summary records). Here is the formula with these included. Note I have not checked this except for syntax.
pattern(aggregate({Amount},{},{yearvalue(Date)=val(2020) and monthvalue(Date)=theMonth and info("summary")=0},{Expenses})
/
aggregate({Time},{},{yearvalue(Date)=val(2020) and monthvalue(Date)=theMonth and info("summary")=0},{Trips}),
“$#,”)
That’s what I get for not checking the documentation before making a post. I am eliminating the info(“visible”) part of the formulas above. Thanks for pointing that out Tom.
pattern(aggregate({Amount},{},{yearvalue(Date)=val(2020) and monthvalue(Date)=02 and info(‘‘summary’‘)=0},{Expenses})
/
aggregate({Time},{},{yearvalue(Date)=val(2020) and monthvalue(Date)=02 and info(‘‘summary’‘)=0},{Trips}),
‘‘$#,’‘)
I get “info( function does not have a [‘SUMMARY] option” .
Again, make sure all the smart quotes are changed to straight quotes. There is definitely an info(“summary”) function. You could even try changing it to info({summary}) just to eliminate all smart quotes. If you intend to do a fair amount of coding I would suggest you turn off smart quotes in the Keyboard/Text panel of your System Preferences if it is turned on.
I had run the formula through Word and switched all smart quotes to non-smart quotes. Obviously, something did not work well. The curly braces have fixed the problem.
This was the last pending issue I had. I only need this database for a specific project, and coding is not something that is a normal part of my activities.
I am much indebted to you and others in this forum because your help has allowed me to achieve what I needed.
Gary got it right with the answer in this case being smart quotes. If you use the Command+ option (to zoom in or magnify your screen’s resolution) on JC’s code, your see the closing quote on his Info(“Summay”) text has 2 opposing quotes (going in the opposite direction.) This is a result of the first one being ‘smarted’ and the second one not. Zooming in on his text is enlightening.
That’s the way how I discovered the apostrophes. The forum always tries to smarten the quotes, but ‘’ does not happen with the double straight quote chr(34).