Forum Discussion
Unwinding annual cumulative data
I have data sets the I receive quarterly and the information is cumulative, so I'm looking for the most succint way to convert it from cumulative to quarterly data in the form of a new column that subtracts the previous period by country and by category.
The first table below is how the data appear now, the second is what I would like to add. I think I could unpivot and just subtract, but hoping there is a better way to perform this in the existing format.
| Country | Supply | Date | Annual Cumulative Amount |
| United States | Computers | 3/31/2020 | 5,000.00 |
| Canada | Computers | 3/31/2020 | 5,000.00 |
| UK | Computers | 3/31/2020 | 5,000.00 |
| United States | Chairs | 3/31/2020 | 6,000.00 |
| Canada | Chairs | 3/31/2020 | 6,000.00 |
| UK | Chairs | 3/31/2020 | 6,000.00 |
| United States | Desk | 3/31/2020 | 7,000.00 |
| Canada | Desk | 3/31/2020 | 7,000.00 |
| UK | Desk | 3/31/2020 | 7,000.00 |
| United States | Monitor | 3/31/2020 | 8,000.00 |
| Canada | Monitor | 3/31/2020 | 8,000.00 |
| UK | Monitor | 3/31/2020 | 8,000.00 |
| United States | Other | 3/31/2020 | 9,000.00 |
| Canada | Other | 3/31/2020 | 10,000.00 |
| UK | Other | 3/31/2020 | 10,000.00 |
| United States | Computers | 6/30/2020 | 10,000.00 |
| Canada | Computers | 6/30/2020 | 12,000.00 |
| UK | Computers | 6/30/2020 | 12,000.00 |
| United States | Chairs | 6/30/2020 | 12,000.00 |
| Canada | Chairs | 6/30/2020 | 14,000.00 |
| UK | Chairs | 6/30/2020 | 14,000.00 |
| United States | Desk | 6/30/2020 | 14,000.00 |
| Canada | Desk | 6/30/2020 | 16,000.00 |
| UK | Desk | 6/30/2020 | 16,000.00 |
| United States | Monitor | 6/30/2020 | 16,000.00 |
| Canada | Monitor | 6/30/2020 | 18,000.00 |
| UK | Monitor | 6/30/2020 | 20,000.00 |
| United States | Other | 6/30/2020 | 20,000.00 |
| Canada | Other | 6/30/2020 | 20,000.00 |
| UK | Other | 6/30/2020 | 24,000.00 |
| United States | Computers | 9/30/2020 | 24,000.00 |
| Canada | Computers | 9/30/2020 | 24,000.00 |
| UK | Computers | 9/30/2020 | 28,000.00 |
| United States | Chairs | 9/30/2020 | 28,000.00 |
| Canada | Chairs | 9/30/2020 | 28,000.00 |
| UK | Chairs | 9/30/2020 | 32,000.00 |
| United States | Desk | 9/30/2020 | 32,000.00 |
| Canada | Desk | 9/30/2020 | 32,000.00 |
| UK | Desk | 9/30/2020 | 36,000.00 |
| United States | Monitor | 9/30/2020 | 40,000.00 |
| Canada | Monitor | 9/30/2020 | 40,000.00 |
| UK | Monitor | 9/30/2020 | 40,000.00 |
| United States | Other | 9/30/2020 | 48,000.00 |
| Canada | Other | 9/30/2020 | 48,000.00 |
| UK | Other | 9/30/2020 | 48,000.00 |
What I would like:
| Country | Supply | Date | Cumulative Amount | Amount Per Period |
| United States | Computers | 3/31/2020 | 5,000.00 | 5,000.00 |
| Canada | Computers | 3/31/2020 | 5,000.00 | 5,000.00 |
| UK | Computers | 3/31/2020 | 5,000.00 | 5,000.00 |
| United States | Chairs | 3/31/2020 | 6,000.00 | 6,000.00 |
| Canada | Chairs | 3/31/2020 | 6,000.00 | 6,000.00 |
| UK | Chairs | 3/31/2020 | 6,000.00 | 6,000.00 |
| United States | Desk | 3/31/2020 | 7,000.00 | 7,000.00 |
| Canada | Desk | 3/31/2020 | 7,000.00 | 7,000.00 |
| UK | Desk | 3/31/2020 | 7,000.00 | 7,000.00 |
| United States | Monitor | 3/31/2020 | 8,000.00 | 8,000.00 |
| Canada | Monitor | 3/31/2020 | 8,000.00 | 8,000.00 |
| UK | Monitor | 3/31/2020 | 8,000.00 | 8,000.00 |
| United States | Other | 3/31/2020 | 9,000.00 | 9,000.00 |
| Canada | Other | 3/31/2020 | 9,000.00 | 9,000.00 |
| UK | Other | 3/31/2020 | 9,000.00 | 9,000.00 |
| United States | Computers | 6/30/2020 | 10,000.00 | 5,000.00 |
| Canada | Computers | 6/30/2020 | 12,000.00 | 7,000.00 |
| UK | Computers | 6/30/2020 | 12,000.00 | 7,000.00 |
| United States | Chairs | 6/30/2020 | 12,000.00 | 6,000.00 |
| Canada | Chairs | 6/30/2020 | 14,000.00 | 8,000.00 |
| UK | Chairs | 6/30/2020 | 14,000.00 | 8,000.00 |
| United States | Desk | 6/30/2020 | 14,000.00 | 7,000.00 |
| Canada | Desk | 6/30/2020 | 16,000.00 | 9,000.00 |
| UK | Desk | 6/30/2020 | 16,000.00 | 9,000.00 |
| United States | Monitor | 6/30/2020 | 16,000.00 | 8,000.00 |
| Canada | Monitor | 6/30/2020 | 18,000.00 | 10,000.00 |
| UK | Monitor | 6/30/2020 | 18,000.00 | 10,000.00 |
| United States | Other | 6/30/2020 | 18,000.00 | 9,000.00 |
| Canada | Other | 6/30/2020 | 20,000.00 | 11,000.00 |
| UK | Other | 6/30/2020 | 24,000.00 | 15,000.00 |
| United States | Computers | 9/30/2020 | 20,000.00 | 10,000.00 |
| Canada | Computers | 9/30/2020 | 20,000.00 | 8,000.00 |
| UK | Computers | 9/30/2020 | 20,000.00 | 8,000.00 |
| United States | Chairs | 9/30/2020 | 24,000.00 | 12,000.00 |
| Canada | Chairs | 9/30/2020 | 24,000.00 | 10,000.00 |
| UK | Chairs | 9/30/2020 | 24,000.00 | 10,000.00 |
| United States | Desk | 9/30/2020 | 28,000.00 | 14,000.00 |
| Canada | Desk | 9/30/2020 | 28,000.00 | 12,000.00 |
| UK | Desk | 9/30/2020 | 28,000.00 | 12,000.00 |
| United States | Monitor | 9/30/2020 | 32,000.00 | 16,000.00 |
| Canada | Monitor | 9/30/2020 | 32,000.00 | 14,000.00 |
| UK | Monitor | 9/30/2020 | 32,000.00 | 14,000.00 |
| United States | Other | 9/30/2020 | 36,000.00 | 18,000.00 |
| Canada | Other | 9/30/2020 | 36,000.00 | 16,000.00 |
| UK | Other | 9/30/2020 | 36,000.00 | 12,000.00 |
3 Replies
- amitchandak
Super User
Anonymous , refer if this can help
Distributing/Allocating the Yearly Target(Convert to Daily Target): Measure ( Daily/YTD): Magic of CLOSINGBALANCEYEAR With TOTALYTD/DATESYTD: https://community.powerbi.com/t5/Community-Blog/Power-BI-Distributing-Allocating-the-Yearly-Target-Convert-to/ba-p/1476400
- AnonymousNot applicable
I read through that article and I don't think it quite gets me what I want. I think I got there with the below, every quarter subtracts the cumulative amount from the previous quarter unless it's Q1, effectively limiting the calcs to be within the same year.
Quarterly Spend = IF(QUARTER(MAX(SAP_quarterly[Date])) = 1, SUM(SAP_quarterly[**bleep**. Ann. Spend]), SUM(SAP_quarterly[**bleep**. Ann. Spend])-CALCULATE(SUM(SAP_quarterly[**bleep**. Ann. Spend]), PREVIOUSQUARTER(SAP_quarterly[Date])))
- AnonymousNot applicable
I've ran into a bug with the above that seems to be a common occurrence in BI, but I can't work out. The formual works properly for displaying a total amount broken out by each quarter. However, if I include all the quarters for a year in a matrix, then the total showing in the matrix is way off even though the subtotals by quarter are accurate. If I display the same data in a waterfall visual, all data is accurate, including the total. Unfortunately I'm unable to share the data, and I realize that makes my question difficult, but does anyone have suggestions I could use so that totals are wrong when I use the above measure? Is there a way to replicate this in Power Query or with a calculated column?