## cumulative percentages

Hi,

I have a dataset where I created a table in Excel that looks like the first example below. That shows, for example that in 2019, number of records for Q1 was 25, and son on. I calculated the Total with a very basic formula. It is easy to replicate it in VA using crosstab. However, I am struggling it to turn it into the second example. My question is, how to calculate Total for each year and then use this number to calculate the percentages? The other tricky part is that the percentages are cumulative in the second example.

Thank you! Sam_SAS
SAS Super FREQ

## Re: cumulative percentages

Hello,

I believe you could calculate this by using two of the periodic operators in VA:

CumulativePeriod will return the year-to-date value for each quarter if you specify ByQuarter as the inner interval and ByYear as the outer interval.

Period will return the value for the current year if you specify ByYear as the interval.

So, you could make an expression like this:

```CumulativePeriod(_Sum_, 'Expenses'n, _IgnoreAllTimeFrameFilters_,
'Quarter'n, _ByQuarter_, _ByYear_, 0, 1, _Full_, {Date}) / Period(_Sum_, 'Expenses'n, _IgnoreAllTimeFrameFilters_, 'Quarter'n,
_ByYear_)```

And get a result like this: This is not exactly the same thing as the data in your opening post. You need the quarter and year to be the same column for this to work. In addition, your report object can only have one date column it for the periodic functions to work. You could work around this somewhat by making an extra character column with the years, for example.

Let us know if that helps,

Sam

Discussion stats
{"ft_lang_label":"__label__en","ft_lang_prob":0.8386983,"math_prob":0.9023965,"size":973,"snap":"2023-40-2023-50","text_gpt3_token_len":227,"char_repetition_ratio":0.11455108,"word_repetition_ratio":0.0,"special_character_ratio":0.22302158,"punctuation_ratio":0.14516129,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9850687,"pos_list":[0,1,2,3,4,5,6,7,8],"im_url_duplicate_count":[null,1,null,null,null,null,null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-11-30T05:43:09Z\",\"WARC-Record-ID\":\"<urn:uuid:685d1311-3f33-426d-adf3-5283ec2d9ac2>\",\"Content-Length\":\"143596\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:02f2a77f-4c93-4aa9-8143-95d629a15c4c>\",\"WARC-Concurrent-To\":\"<urn:uuid:35e32a3b-b255-4ec2-95e4-4d3b5e9ad506>\",\"WARC-IP-Address\":\"18.67.65.81\",\"WARC-Target-URI\":\"https://communities.sas.com/t5/SAS-Visual-Analytics/cumulative-percentages/td-p/862533\",\"WARC-Payload-Digest\":\"sha1:V7EFGWEPYZAOGKD6HNMJEUHVMY5B2ECL\",\"WARC-Block-Digest\":\"sha1:3KNR3NB4RJZVH2IRI75CJCYVJ6AXHZHL\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100164.87_warc_CC-MAIN-20231130031610-20231130061610-00175.warc.gz\"}"}