Calculate VBA Key Figure On Excel
Calculate VBA Key Figure On Excel
Applies to:
Bex Reporting using Workbooks in BI 7.0. For more information, visit the Business Intelligence homepage
Summary
This article is a step by step guidance for using VBA Code in a Bex Workbook Requirement is to calculate Ratings based on Ratio field in Bex Report. As Bex is not capable of filling with a constant Value, the Options we have are: 1) Add this field to Info Provider and use a Routine in the update Rule or 2) Write VBA code in the workbook. Author: Sukthi Sattenapalli
Author Bio
Author is BW-BI Senior Consultant having worked in MNC/multi Country/multi Currency environment (US, Netherlands, Malaysia) in all phases of BI/BW Project implementations and played a crucial role in Upgrade Projects from 3.X to BI 7.0.
Table of Contents
Bex Report: .........................................................................................................................................................3 Requirement of Constant values in Report:........................................................................................................4 Visual Basic Editor:.............................................................................................................................................4 VB Code:.............................................................................................................................................................5 Related Content..................................................................................................................................................8 Disclaimer and Liability Notice............................................................................................................................9
Bex Report:
There is a report with characteristics and KFs as Below Material Material Freight Class
To solve this first we need to a formula variable to Query and set its value to some value like 0
VB Code:
Add Below Code there Set ws = ThisWorkbook.ActiveSheet lngLastRow = ws.Range("A65000").End(xlUp).Row
For lngRow = lngLastRow - 1 To 1 Step -1 If ws.Range("A" & lngRow).Font.Bold Then Exit For If IsEmpty(ws.Range("A" & lngRow)) Then lngRow = ws.Range("A" & lngRow).End(xlUp).Row + 1 End If Next lngRow ws.Range("A" & lngRow).Select Set rgScope = ActiveCell.CurrentRegion lngLastRow = rgScope.Rows.Count + rgScope.Row - 1
For i = 1 To 10
Case Is >= 10 rgScope.Rows.Cells(j, i) = "C" Case Is >= 5 rgScope.Rows.Cells(j, i) = "B" Case Is < 5 rgScope.Rows.Cells(j, i) = "A"
Case Else rgScope.Rows.Cells(j, i) = "X" End Select And call the Module Name in SAPBEXon Refresh.
When Report is executed we can see the new ratings calculated in the Result area:
Related Content
How to integrate Bex with VB http://help.sap.com/saphelp_nw04/helpdata/en/ba/45583ca544eb51e10000000a114084/frameset.htm https://www.sdn.sap.com/irj/scn/thread?messageID=1719655 For more information, visit the Business Intelligence homepage.