/wp-content/uploads/2014/03/dashboard_405659.jpg

Requirement and issues

  • A component such as a chart or a table (referred to from now on as “the affected component”) must be filtered using two combo boxes representing “From” and “To” months.
  • The platform used is Dashboards sp02 over BW using SAP Netweaver BW connections built in the Dashboards Data Manager.
  • The months in the “To” combo must be greater than the selected month in the “From” combo.
  • For the year 2010, month values returned have formatting problems (1.201 instead of 01.2010)
  • Refreshing the affected component according to the cell containing the calculated “from-to” range results in a bex error regarding a mandatory variable that was not filled.

Solution Overview

  • Use “insert selected value” from the combos to get the selected “from” and “to” values.
  • Use a BEX user exit variable in order to create a query that returns all the months that are greater than a given month.
  • Use an excel formula to fix the problem with 2010 values.
  • Refresh the affected component according to the change of the “To” value rather than a change in the range to avoid a BEX error.

Detailed Solution

  

The Months-To query

The first order of business is to create a query that returns all the months that are greater than a given month. We do this by using an input variable to get the given month on a selection within the key figure structure of the query. We then calculate the “greater than” restriction in a user-exit variable in the characteristic restrictions for the query.

  1. Create a query on the source
    data with 0calmonth in the rows and two hidden selections in the columns.
  2. In one of the selections in the key figure structure,
    use a month selection variable to filter its value.

/wp-content/uploads/2014/03/1_319137.jpg

3. Then create a user-exit variable for 0calmonth and use it in the characteristics restrictions panel for the query . The code for the variable is presented below.

/wp-content/uploads/2014/03/2_319138.jpg

WHEN ‘ZMONG_UEX’.

    IF I_STEP <> 2.

      RAISE no_processing.

    ELSE.

      CLEAR L_S_RANGE.

      L_S_RANGEOPT = ‘GE’.

      L_S_RANGESIGN = ‘I’.

      LOOP AT I_T_VAR_RANGE INTO W_T_VAR_RANGE.

        CASE W_T_VAR_RANGEVNAM.

          WHEN ‘ZMONT_SNG’.

            L_S_RANGELOW = W_T_VAR_RANGELOW.

            APPEND L_S_RANGE TO E_T_RANGE.

        ENDCASE.

      ENDLOOP.

    ENDIF.

Linking the data and spreadsheet calculations

Create data sources for the “from” query, the “to” query and the query for the affected component. Link the result (“Cross-Tab data”) for each query to a place on the embedded spreadsheet.

Once you’ve linked the data to the spreadsheet,  use the combos’ “insert selected item” function to put the selected value in a cell in the spreadsheet (I usually use the cell above the results, and color it).

/wp-content/uploads/2014/03/3_319208.jpg

You might encounter a problem with the year 2010, showing up as “1.201” instead of “01.2010”. in order to fix this issue, use the following excel formula, where L3 is the cell into which the data was inserted.

=IF(LEFT(RIGHT(L3,4),1)=”.”,IF(LEFT(L3,1)=”0″,L3&”0″,0&L3&0),L3)

You might also want to hide the “0” value with an additional formula:

=IF(M3=0,””,M3)

Make sure to link the final calculated value for the result of the “from” query to a variable in the data connection of the “to” query:

/wp-content/uploads/2014/03/4_319209.jpg

Getting the final value for the months range (e.g. 01.2010 – 02.2010) , where P3 is the calculated from value and Q3 is the calculated to value:

=IF(P3=””,””,IF(Q3=””,P3&” – “&P3,P3&” – “&Q3))

Where P3 is the cell with the calculated from value and Q3 is the cell with the calculated to value.

Link the cell with final calculated value for the months range to a variable in the data connection of the affected component.

/wp-content/uploads/2014/03/5_319210.jpg

However, DO NOT use the cell with the range as a trigger cell for refreshing that data connection. Instead, use the cell with the calculated “TO” value as the trigger (in this example, Q3).

This may sound counter-intuitive, but at least in my case using the cell with the range created a BEX error regarding a missing value for a mandatory variable (while none of the variables are, in fact, mandatory). This will also work because any change to the “from” value will automatically refresh the “to” value as well. As a bonus, this creates a nifty effect where the range between the selected values in the “from” and “to” combos is always kept the same (that is, 01.2009 – 12.2009 becomes 01.2010 – 12.2010 when you change the from date).

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply