As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
I am trying to calculate an average column and having problem with it. I am providing CAR as example. In my scenario CAR field is replaced by week starting date column. So, every week start date will have 1 record.
TABLE FILE CAR
SUM
SALES
BY CAR
WHERE SALES GT 0;
END
CAR SALES AVG
ALFA ROMEO 30200 30200
AUDI 7800 19000
BMW 80390 39463
DATSUN 43000 40347
JAGUAR 12000 35797
Above code provides CAR and SALES column. I am trying to create AVG column with those values. Basically value for AVG column in a row would be average of SALES in its row and 3 rows above (total 4 including its row). If 4 rows are not available, it would be average of whatever rows that are available but 4 is max.
So, for AUDI, 19000 is average of 7800 and 30200. BMW, 39463 is average of 80390,7800 and 30200. Jaguar, 35797 is average of 12000,43000,80390 and 7800. If there is one more car, AVG for that would be average of its own SALES value, 12000, 43000 and 80390.
Please suggest.This message has been edited. Last edited by: Enigma006,
TABLE FILE CAR
SUM
SALES
COMPUTE PREV_SALES1/D12.2=LAST SALES;
COMPUTE PREV_SALES2/D12.2=LAST PREV_SALES1;
COMPUTE PREV_SALES3/D12.2=LAST PREV_SALES2;
COMPUTE AVG_SALES/D12.2= (SALES + PREV_SALES1 + PREV_SALES2 + PREV_SALES3)/4;
BY CAR
WHERE SALES GT 0;
END
Enigma,
Is it always a trailing 4 weeks? If so you could you employ the LAST command as such to receive your desired outcome.
Thanks!
Eric Woerle 8.1.05M Gen 913- Reporting Server Unix 8.1.05 Client Unix Oracle 11.2.0.2
Posts: 750 | Location: Warrenville, IL | Registered: January 08, 2013
Yes Eric. Its maximum 4 weeks. If only 2 records are available, it should be average for those 2, if 3 then 3 and 4 is max. Below code assumes 4 everything. I am trying to tweak it to work for other cases.
quote:
Originally posted by eric.woerle:
TABLE FILE CAR
SUM
SALES
COMPUTE PREV_SALES1/D12.2=LAST SALES;
COMPUTE PREV_SALES2/D12.2=LAST PREV_SALES1;
COMPUTE PREV_SALES3/D12.2=LAST PREV_SALES2;
COMPUTE AVG_SALES/D12.2= (SALES + PREV_SALES1 + PREV_SALES2 + PREV_SALES3)/4;
BY CAR
WHERE SALES GT 0;
END
Enigma,
Is it always a trailing 4 weeks? If so you could you employ the LAST command as such to receive your desired outcome.
Thanks!
This message has been edited. Last edited by: Enigma006,