Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Consecutive Days Under Budget GGSALES
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Consecutive Days Under Budget GGSALES
 Login/Join
 
Gold member
posted
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.04 (Dev)
 
Posts: 59 | Location: OK | Registered: November 19, 2015Reply With QuoteReport This Post
Silver Member
posted Hide Post
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
 
Posts: 43 | Location: Odessa, Florida | Registered: July 26, 2011Reply With QuoteReport This Post
Gold member
posted Hide Post
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.04 (Dev)
 
Posts: 59 | Location: OK | Registered: November 19, 2015Reply With QuoteReport This Post
Virtuoso
posted Hide Post
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.0.1M gen 240, Dev 8.2.04 gen 48, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2172 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Gold member
posted Hide Post
Perfect, that CONSEC calculation was what I had trouble with. Thank you.


WF 8.0.08 (Prod); WF 8.2.04 (Dev)
 
Posts: 59 | Location: OK | Registered: November 19, 2015Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Consecutive Days Under Budget GGSALES

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.