Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Gaelledt1
Contributor II
Contributor II

Aggregated Range Sum in the script

Hello everyone,

I have this expression in a chart. I would like to put it in the script, but I do not know what to do.

I have a product table with Product part number, Shipped Flag, Shipped Qty and Shipped date. In the chart I use the following expression:

AGGR(
             RANGESUM(ABOVE(

            SUM({< ShipFlag={1},

                           ShipDate={">=$(=MonthStart(Addmonths(TODAY(),-6))) < $(=MonthStart(Today()))"}
                           >}ShippedQty),0,RowNo()))
            /
          SUM({< ShipFlag={1},
                          ShipDate={">=$(=MonthStart(Addmonths(TODAY(),-6))) < $(=MonthStart(Today()))"}
                         >}TOTAL ShippedQty)
,
(PartNum,(=SUM({< ShipFlag={1},
                                      ShipDate={">=$(=MonthStart(Addmonths(TODAY(),-6))) < $(=MonthStart(Today()))"}
                                        >}OurStockShippedQty),DESC)))

 

I tried the following:

Table1:
LOAD

PartNum
,SUM(ShippedQty) AS PartSum

Resident ProductTable
Where ShipFlag = 1
And ShipDate >= MonthStart(Addmonths(TODAY(),-6))
And ShipDate < MonthStart(Today())
Group by PartNum
;

 

Table2:
LOAD *

,Rangesum(SUM(PartSum), Peek(PartSum)) AS PartTotalSum

Resident Table1;
Drop Table Table1;

Table3:
LOAD *,

PartSum/PartTotalSum AS Percentage

RESIDENT Table2;

DROP TABLE Table2;

 

The loading process is failing because of "invalid expression".

Your help would be much appreciated.

Thank you very much!

0 Replies