Its a bit hard to help you troubleshoot without actually seeing the workbook. With that said, troubleshooting tips for that error are featured in the Tableau help documentation. I would recommend that you check out the article:
MAX isn't supported in all data sources. Check what you're using and change to something that works.
The quick solution will be to change both data sources to extracts, but that would depend on your situation.