Focal Point
[SOLVED] Consecutive Days Under Budget GGSALES

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/8277077096

September 17, 2018, 03:45 PM
evan.brown
[SOLVED] Consecutive Days Under Budget GGSALES
I'm having problems wrapping my head around doing a calculation. I'm trying to figure if the latest day of sales is under budget, how many consecutive days were sales under budget.

Using the following from GGSALES:
  
TABLE FILE GGSALES
SUM
UNITS
BUDUNITS
COMPUTE UNDERBUD/I1=BUDUNITS GE UNITS;
BY PRODUCT
BY HIGHEST DATE
END


I would expect the results to be:
Biscotti 1
Capuccino 1
Coffee Grinder 1
Croissant 1
Espresso 1
Latte 1
Mug 2
Scone 1
Thermos 2

Thank for the help!

This message has been edited. Last edited by: FP Mod Chuck,


WF 8.0.08 (Prod); WF 8.2.06 (Dev)
September 17, 2018, 04:26 PM
MReeder
I am not sure you are asking for what you really need. The above file the dates are unique and therefore BY HIGHEST DATE will the same as BY DATE. from the example data you have given you are calculating based on the last two months of sales.

You can achieve these results with this code but I am not convinced this is really what you want. Could you give a better description of what you are trying to achieve?

 

TABLE FILE GGSALES
SUM
UNITS
BUDUNITS
COMPUTE UNDERBUD/I1=BUDUNITS GE UNITS;
BY PRODUCT
BY  HIGHEST 2 DATE 
ON TABLE HOLD AS H1
END

TABLE FILE H1
SUM UNDERBUD
BY PRODUCT
END

 



WebFOCUS 8.2.02M
Windows
Server/8.2.02M
All Outputs
September 17, 2018, 04:33 PM
evan.brown
BY HIGHEST DATE gives me the most recent date to the least most recent date. By DATE sorts the other way around. I'm looking for what's happening since the most recent date.

I want to see:
1. How many consecutive days of sales has UNDERBUD been 1, when
2.The most recent day has an UNDERBUD of 1.

This message has been edited. Last edited by: evan.brown,


WF 8.0.08 (Prod); WF 8.2.06 (Dev)
September 18, 2018, 08:10 AM
MartinY
quote:

MReeder said :
therefore BY HIGHEST DATE will the same as BY DATE

When not specified (by default) a BY is always accomplish with LOWEST as the order.
Which mean that the order is done by the lowest to the greatest value. So a BY HIGHEST is ordering by the greatest to the lowest value; it doesn't make the same result.

Something such as this may suits your need.
I have convert the date to YY-MM just for the sample.
DEFINE FILE GGSALES
YRMTH /YYM = DATE
END
TABLE FILE GGSALES
SUM UNITS
    BUDUNITS
    COMPUTE UNDERBUD/I1=BUDUNITS GE UNITS;
BY PRODUCT
BY YRMTH
ON TABLE HOLD AS EXTDATA
END
-RUN

DEFINE FILE EXTDATA
CONSEC /P3 = IF LAST PRODUCT EQ PRODUCT THEN 
                (IF LAST UNDERBUD EQ 1 AND UNDERBUD EQ 1 THEN CONSEC + 1 ELSE (IF UNDERBUD EQ 1 THEN 1 ELSE 0))
			 ELSE (IF UNDERBUD EQ 1 THEN 1 ELSE 0);
END
TABLE FILE EXTDATA
SUM UNITS
    BUDUNITS
    UNDERBUD
    CONSEC
BY PRODUCT
BY YRMTH
ON TABLE HOLD AS RPTDATA
END
-RUN

DEFINE FILE RPTDATA
ISUNDERBDG /A3 = IF CONSEC GT 0 THEN 'Yes' ELSE 'No';
END
TABLE FILE RPTDATA
PRINT ISUNDERBDG AS 'Current Mth,Under,Budget'
      CONSEC     AS 'Nb Consecutive Mth,Under Budget'
BY PRODUCT
BY HIGHEST 1 YRMTH NOPRINT
ON TABLE SET PAGE-NUM NOLEAD
END



WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
September 18, 2018, 08:44 AM
evan.brown
Perfect, that CONSEC calculation was what I had trouble with. Thank you.


WF 8.0.08 (Prod); WF 8.2.06 (Dev)