How to Calculate the Days in a Selected Period SAP BW Report [Tutorial]

Table of Contents

How to Calculate a Period of Time in SAP BW

No Customer Exit Required!

Have you ever needed to calculate the number of days in a selected period for a report (without using a customer exit!) in SAP BW?    That’s right, you can do it entirely without resorting to a customer exit, thus avoiding coding and drastically improving Total Cost of Ownership (TCO).

Uses of Days in Period

 

Business Scenario:  You need to calculate some personnel metrics like equivalent labor class or craft their related loaded cost. The formula is to take the the total number of absences and divide by the number of available work days (the client doesn't have the system calendar set to give work days, and they change the number of work days at report execution time).

Just follow the steps below and you can easily do the calculation:

 

1.  Create a new calculated Key Figure
2.  Create a new formula variable 

Calculated Key Figure

3.  Make selections similar to what you see in this screen. We will process by replacement path and reference characteristic 0CALDAY. 0CALDAY is used in this report as the main date field and the user is prompted to enter a Date From and Date to in the same variable (a mandatory interval variable).


Display Variable 2 resized 600

4.  Go to the Replacement Path tab. Here you will enter the name of the variable used on 0CALDAY and define the “replace variable with” to ‘variable’. We also change the “Use Interval” to ‘Difference’. This will give us the difference between the two selected dates.

Based on InfoCube

BEx Query Designer XBO resized 600

 

5.  Finally, use this newly created formula variable in the new calculated key figure. 

 
Display Calculated Key Figure resized 600

Figure 1 - Query definition showing 0CALDAY filter and the variable used

 

6.  Now you can insert this calculated key figure into your report. You will get a column that repeats the result for each row. This can be handy for other calculations such as calculating the number of available workdays in a period. (In our case, the user enters the number of workdays manually at the report prompt screen). Then we calculated the number of weeks times the number of workdays and used the result for our final metric.   

Final Result resized 600

 

Figure 2 - Final Result

 

 

There you have it, a solution to one of the most common tasks a BW Consultant needs to solve on a project. 

 

Want to have a copy of this tutorial for future reference?  Click the button to get your copy.

 

Download the Tutorial  on  How to Calculate  the Number of Days in a Period

 

Do You Have Any Other Tips to Share or Problems You Need Some Help With?

 

Thanks

 

More reading:

1 Key Tip When Upgrading from SAP BW 3.X to BW 7.X [Checklist]

10 Advanced SAP BW Project Estimation Techniques [Online Tool]

Learn What is Catch Weight Management

Top 10 Benefits for Financial Analysis in the Latest SAP EP4

BusinessObjects Explorer Best Practices

 

 

Download SAP BW Mindmap

Learn what SAP Business Warehouse is and what it does in under five minutes

Get this Mindmap

Victor Ayers

Victor is a SAP Certified SAP Business Warehouse and BusinessObjects Consultant with deep SAP HANA architecture expertise.

View All Articles by Victor Ayers

The SAP Blog

Subscribe to our blog and receive SAP BW Updates, demand generation, inbound marketing, sales enablement, technology and revenue generation insights and ideas delivered right to your email.