Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
AmirKilkr
Contributor
Contributor

Simple table accumulation issue

Hello members,

I have an issue, I cant create the accumulation in the table below as needed in the following picture:

AmirKilkr_1-1645600817842.png

 

 

This is the script:

SalesAggFinal:

LOAD
YearMonth,
"Group",
Quantity,
TotalPriceBeforVat,
TotalPriceBeforVat/Quantity as unitprice
FROM [lib://DB/SalesAggFinal.qvd]
(qvd);

SalesAggAcc:

LOAD "Group",
YearMonth,
TotalPriceBeforVat, RangeSum(peek('Cumulative') , TotalPriceBeforVat) AS TotalPriceBeforVatCumulative

Resident SalesAggFinal;

 

exit script

Table after accumulation:

AmirKilkr_0-1645600716222.png

****Table before the accumulation ******

 

AmirKilkr_0-1645600504650.png

 

Labels (3)
1 Solution

Accepted Solutions
rubenmarin

Hi, I see that YearMonth is leaft aligned, meaning the it's being loaded as a text, not a date, and it would be sorted alphabetically, not by date, so Feb comes first, then Jan and lastly Mar.

Check where are you creating this field and use one that is really a date, you can also crete one from this field using something like Date(Date#(YearMonth,'YYYY-MMM'),'YYYY-MMM') as YearMonthAsDate.

View solution in original post

4 Replies
rubenmarin

Hi, try with:

SalesAggAcc:
LOAD "Group",
YearMonth,
TotalPriceBeforVat, 
If(Group=Peek(Group)
  ,RangeSum(peek('TotalPriceBeforVatCumulative'), TotalPriceBeforVat)
  ,TotalPriceBeforVat
) AS TotalPriceBeforVatCumulative
Resident SalesAggFinal
Order By Group, YearMonth;

I added a check to not accumualte different groups, if you want to accumulate differnt droups you can remove the order by and the If.

AmirKilkr
Contributor
Contributor
Author

Hi Ruben

The number still not adding up correctly 

AmirKilkr_0-1645631099984.png

 

rubenmarin

Hi, I see that YearMonth is leaft aligned, meaning the it's being loaded as a text, not a date, and it would be sorted alphabetically, not by date, so Feb comes first, then Jan and lastly Mar.

Check where are you creating this field and use one that is really a date, you can also crete one from this field using something like Date(Date#(YearMonth,'YYYY-MMM'),'YYYY-MMM') as YearMonthAsDate.

AmirKilkr
Contributor
Contributor
Author

Thank you Ruben