Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

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. 

 

CountrySupplyDate Annual Cumulative Amount 
United StatesComputers3/31/2020                                          5,000.00
CanadaComputers3/31/2020                                          5,000.00
UKComputers3/31/2020                                          5,000.00
United StatesChairs3/31/2020                                          6,000.00
CanadaChairs3/31/2020                                          6,000.00
UKChairs3/31/2020                                          6,000.00
United StatesDesk3/31/2020                                          7,000.00
CanadaDesk3/31/2020                                          7,000.00
UKDesk3/31/2020                                          7,000.00
United StatesMonitor3/31/2020                                          8,000.00
CanadaMonitor3/31/2020                                          8,000.00
UKMonitor3/31/2020                                          8,000.00
United StatesOther3/31/2020                                          9,000.00
CanadaOther3/31/2020                                       10,000.00
UKOther3/31/2020                                       10,000.00
United StatesComputers6/30/2020                                       10,000.00
CanadaComputers6/30/2020                                       12,000.00
UKComputers6/30/2020                                       12,000.00
United StatesChairs6/30/2020                                       12,000.00
CanadaChairs6/30/2020                                       14,000.00
UKChairs6/30/2020                                       14,000.00
United StatesDesk6/30/2020                                       14,000.00
CanadaDesk6/30/2020                                       16,000.00
UKDesk6/30/2020                                       16,000.00
United StatesMonitor6/30/2020                                       16,000.00
CanadaMonitor6/30/2020                                       18,000.00
UKMonitor6/30/2020                                       20,000.00
United StatesOther6/30/2020                                       20,000.00
CanadaOther6/30/2020                                       20,000.00
UKOther6/30/2020                                       24,000.00
United StatesComputers9/30/2020                                       24,000.00
CanadaComputers9/30/2020                                       24,000.00
UKComputers9/30/2020                                       28,000.00
United StatesChairs9/30/2020                                       28,000.00
CanadaChairs9/30/2020                                       28,000.00
UKChairs9/30/2020                                       32,000.00
United StatesDesk9/30/2020                                       32,000.00
CanadaDesk9/30/2020                                       32,000.00
UKDesk9/30/2020                                       36,000.00
United StatesMonitor9/30/2020                                       40,000.00
CanadaMonitor9/30/2020                                       40,000.00
UKMonitor9/30/2020                                       40,000.00
United StatesOther9/30/2020                                       48,000.00
CanadaOther9/30/2020                                       48,000.00
UKOther9/30/2020                                       48,000.00

 

What I would like:

CountrySupplyDate Cumulative Amount  Amount Per Period 
United StatesComputers3/31/2020                             5,000.00                       5,000.00
CanadaComputers3/31/2020                             5,000.00                       5,000.00
UKComputers3/31/2020                             5,000.00                       5,000.00
United StatesChairs3/31/2020                             6,000.00                       6,000.00
CanadaChairs3/31/2020                             6,000.00                       6,000.00
UKChairs3/31/2020                             6,000.00                       6,000.00
United StatesDesk3/31/2020                             7,000.00                       7,000.00
CanadaDesk3/31/2020                             7,000.00                       7,000.00
UKDesk3/31/2020                             7,000.00                       7,000.00
United StatesMonitor3/31/2020                             8,000.00                       8,000.00
CanadaMonitor3/31/2020                             8,000.00                       8,000.00
UKMonitor3/31/2020                             8,000.00                       8,000.00
United StatesOther3/31/2020                             9,000.00                       9,000.00
CanadaOther3/31/2020                             9,000.00                       9,000.00
UKOther3/31/2020                             9,000.00                       9,000.00
United StatesComputers6/30/2020                           10,000.00                       5,000.00
CanadaComputers6/30/2020                           12,000.00                       7,000.00
UKComputers6/30/2020                           12,000.00                       7,000.00
United StatesChairs6/30/2020                           12,000.00                       6,000.00
CanadaChairs6/30/2020                           14,000.00                       8,000.00
UKChairs6/30/2020                           14,000.00                       8,000.00
United StatesDesk6/30/2020                           14,000.00                       7,000.00
CanadaDesk6/30/2020                           16,000.00                       9,000.00
UKDesk6/30/2020                           16,000.00                       9,000.00
United StatesMonitor6/30/2020                           16,000.00                       8,000.00
CanadaMonitor6/30/2020                           18,000.00                    10,000.00
UKMonitor6/30/2020                           18,000.00                    10,000.00
United StatesOther6/30/2020                           18,000.00                       9,000.00
CanadaOther6/30/2020                           20,000.00                    11,000.00
UKOther6/30/2020                           24,000.00                    15,000.00
United StatesComputers9/30/2020                           20,000.00                    10,000.00
CanadaComputers9/30/2020                           20,000.00                       8,000.00
UKComputers9/30/2020                           20,000.00                       8,000.00
United StatesChairs9/30/2020                           24,000.00                    12,000.00
CanadaChairs9/30/2020                           24,000.00                    10,000.00
UKChairs9/30/2020                           24,000.00                    10,000.00
United StatesDesk9/30/2020                           28,000.00                    14,000.00
CanadaDesk9/30/2020                           28,000.00                    12,000.00
UKDesk9/30/2020                           28,000.00                    12,000.00
United StatesMonitor9/30/2020                           32,000.00                    16,000.00
CanadaMonitor9/30/2020                           32,000.00                    14,000.00
UKMonitor9/30/2020                           32,000.00                    14,000.00
United StatesOther9/30/2020                           36,000.00                    18,000.00
CanadaOther9/30/2020                           36,000.00                    16,000.00
UKOther9/30/2020                           36,000.00                    12,000.00

 

3 Replies

    • Anonymous's avatar
      Anonymous
      Not 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])))
  • Anonymous's avatar
    Anonymous
    Not 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?