it often happens that while developing a workbook in analyzer

Upload: saurabh840

Post on 14-Apr-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/29/2019 It Often Happens That While Developing a Workbook in Analyzer

    1/7

    It often happens that while developing a workbook in analyzer, we come across a need from the user

    which can be easily dealt with by writing small macro codes in our workbook.

    In this document, I have mentioned the specific steps for creating and embedding a macro code in the

    workbook, I have illustrated this with the help of few scenarios.

    Scenario 1:

    The requirement is to develop a report which shows the forecast accuracy of various products. The

    accuracy is calculated at different levels like plant level, national level, zone level etc.

    Why we needed macro:

    The BEX query has 31 selections in the key figure structure, each representing a date in a month.

    In analyzer, the output of this query will mapped to another locally created table which has to show

    rolling sum.

    This table will then be used to draw a graph representing daily sales.

    Divisions Day1 Day2 Day2 Day3 Day4 Day5 Day6

    A 100 50 90 100 900 500 300

    B 200 300 300 500 100 200 400

    Table 2 is being filled up by table 1, which actually is BEX query. The excel formula to add up the

    previous cell has been applied to all the cells.

    This causes an issue; all the cells up to Day31 get filled up in table 2. Because of this, the graph which

    has been mapped to table 2 to show daily accumulated sales shows values till day 31. We want the

    graph to show the data till current day -1.

    This can be easily achieved using the macros. With a macro code well check the current date and then

    delete the values from all the cells which fall after the required day.

    Divisions Day1 Day2 Day2 Day3 Day4 Day5 Day6

    A 100 150 240 340 1240 1750 2050

    B 200 500 800 1300 1400 1600 2000

  • 7/29/2019 It Often Happens That While Developing a Workbook in Analyzer

    2/7

    The tables created in Analyzer:

    The graph is mapped to table 2 and appears as following:

    Here we see that the lines appear till day 15, actually they should have appeared till current date only.

  • 7/29/2019 It Often Happens That While Developing a Workbook in Analyzer

    3/7

    To view the VBA editor just go to the sheets and right click on them:

    A list of the options appears as shown in the above screenshot. Select the View code opt ion to startthe editor. The initial editor looks like the following:

    All the sheets present in the workbook are listed

    here. They are named as sheet1, sheet2 etc. In

    program that write, we always refer to them as

    sheet1, sheet2 etc and not by the description that

    we provide to the sheets.

    This shows the various properties of the

    sheet.

    This is the actual editor area where we write the code

  • 7/29/2019 It Often Happens That While Developing a Workbook in Analyzer

    4/7

    In the present case, we want the code to be executed when the sheet is activated. So we select the

    Activate function.

    The code has been written to populate the table for the graph up to the current day only:

  • 7/29/2019 It Often Happens That While Developing a Workbook in Analyzer

    5/7

    The table from which the graph draws its data appears as follows:

    The line in the graph appears till the current date only:

    This is a very simple situation which I have come across; there might be several situations where a

    simple VBA code can resolve a complex issue. Most of the time, BW consultants tend to overlook the

    usefulness of the power of excel that is inherently added to the analyzer along with the BEX.

  • 7/29/2019 It Often Happens That While Developing a Workbook in Analyzer

    6/7

    APE = forecast-sales/sales

    Material plant Sales-total

    quantity

    Forecast price Totalvalue

    APE Abs value(totalvalue*APE)

    Forecastaccuracy(1-

    Abs

    value/total

    value)

    10000 1 600 900 10 6000 0.5 3000 0.5

    10000 2 400 500 10 4000 0.25 1000 0.75

    10000 3 100 80 10 1000 0.2 200 0.8

  • 7/29/2019 It Often Happens That While Developing a Workbook in Analyzer

    7/7

    10000 4 500 700 10 5000 0.4 2000 0.6

    Material Sales-

    total

    quantity

    Forecast price Total

    value

    APE Abs value(total

    value*APE)

    Forecast

    accuracy(1-

    Abs

    value/total

    value)

    10000 1600 2180 10 16000 0.3625 580 0.9

    BEX was calculating the Abs value by summing up the individual values which in this case would be 6200.

    So the accuracy was calculated as : 6200/16000 =