Grouped by Account And/Or Hanlder? Also is Prior YTD the YTD before this transaction or the Prior Year's YTD to the same point?
Generally, I would split month/year (using formula or parse), then sort on both, then use multi row formulas to calculate YTD and QTD. The priors depend on the definition of prior, a second multi row formula if it's the value before current or calculate the prior year and the join with itself if it is the Prior Year YTD.