Skip to content
NextLytics
Megamenü_2023_Über-uns

Shaping Business Intelligence

Whether clever add-on products for SAP BI, development of meaningful dashboards or implementation of AI-based applications - we shape the future of Business Intelligence together with you. 

Megamenü_2023_Über-uns_1

About us

As a partner with deep process know-how, knowledge of the latest SAP technologies as well as high social competence and many years of project experience, we shape the future of Business Intelligence in your company too.

Megamenü_2023_Methodik

Our Methodology

The mixture of classic waterfall model and agile methodology guarantees our projects a high level of efficiency and satisfaction on both sides. Learn more about our project approach.

Products
Megamenü_2023_NextTables

NextTables

Edit data in SAP BW out of the box: NextTables makes editing tables easier, faster and more intuitive, whether you use SAP BW on HANA, SAP S/4HANA or SAP BW 4/HANA.

Megamenü_2023_Connector

NextLytics Connectors

The increasing automation of processes requires the connectivity of IT systems. NextLytics Connectors allow you to connect your SAP ecosystem with various open-source technologies.

IT-Services
Megamenü_2023_Data-Science

Data Science & Engineering

Ready for the future? As a strong partner, we will support you in the design, implementation and optimization of your AI application.

Megamenü_2023_Planning

SAP Planning

We design new planning applications using SAP BPC Embedded, IP or SAC Planning which create added value for your company.

Megamenü_2023_Dashboarding

Dashboarding

We help you with our expertise to create meaningful dashboards based on Tableau, Power BI, SAP Analytics Cloud or SAP Lumira. 

Megamenü_2023_Data-Warehouse-1

SAP Data Warehouse

Are you planning a migration to SAP HANA? We show you the challenges and which advantages a migration provides.

Business Analytics
Megamenü_2023_Procurement

Procurement Analytics

Transparent and valid figures are important, especially in companies with a decentralized structure. SAP Procurement Analytics allows you to evaluate SAP ERP data in SAP BI.

Megamenü_2023_Reporting

SAP HR Reporting & Analytics

With our standard model for reporting from SAP HCM with SAP BW, you accelerate business activities and make data from various systems available centrally and validly.

Megamenü_2023_Dataquality

Data Quality Management

In times of Big Data and IoT, maintaining high data quality is of the utmost importance. With our Data Quality Management (DQM) solution, you always keep the overview.

Career
Megamenü_2023_Karriere-2b

Working at NextLytics

If you would like to work with pleasure and don't want to miss out on your professional and personal development, we are the right choice for you!

Megamenü_2023_Karriere-1

Senior

Time for a change? Take your next professional step and work with us to shape innovation and growth in an exciting business environment!

Megamenü_2023_Karriere-5

Junior

Enough of grey theory - time to get to know the colourful reality! Start your working life with us and enjoy your work with interesting projects.

Megamenü_2023_Karriere-4-1

Students

You don't just want to study theory, but also want to experience it in practice? Check out theory and practice with us and experience where the differences are made.

Megamenü_2023_Karriere-3

Jobs

You can find all open vacancies here. Look around and submit your application - we look forward to it! If there is no matching position, please send us your unsolicited application.

Blog
NextLytics Newsletter Teaser
Sign up now for our monthly newsletter!
Sign up for newsletter
 

Combining Date and Factory Calendar Data in SAP Datasphere

Calendar datasets are foundational for many analytics and planning models, but they often require enhancements to unlock their full potential. In this article, we’ll walk through how to create a unified calendar view in SAP Datasphere by combining standard “date” data with factory calendar working days from SAP S/4HANA. The result will be a dataset that clearly identifies working and non-working days for specific regions, using SQL scripting.

Understanding Factory Calendars in SAP S/4HANA

A factory calendar in SAP S/4HANA defines working and non-working days for specific regions or business units, enabling accurate scheduling, production planning, and deadline calculations. These calendars store rules such as public holidays, weekends, and custom non-working days. Key CDS views like I_FACTORYCALENDAR (master data for calendar IDs and validity periods) and I_FACTORYCALENDARTEXT (language-specific descriptions) define calendar data, while I_PUBLICHOLIDAYCALENDAR and I_PUBLHOLIDAYCALHOLIDAYDATE provide public holiday rules and exact holiday dates. 

For fiscal reporting, I_FISCALCALENDARDATE maps dates to fiscal periods. 

In this article, we’ll use I_FACTORYCALWORKINGDAYSPERYR, which compresses monthly working days into encoded strings (e.g., “11100…”), to enrich standard date dimensions. To leverage these views, ensure they’re replicated into SAP Datasphere via replication flows using the CDS Views as a source. 

Data Sources and Setup

1. SAP.TIME.M_TIME_DIMENSION

This default view in SAP Datasphere contains comprehensive date information, including:

  • DATE_SQL: Calendar dates

  • YEAR, MONTH, QUARTER: Hierarchical time divisions

  • Week and day identifiers

Prerequisite: Activate this view in your Datasphere space.

Date data image 1_Date and Factory Calendar Data

A table showing dates, years, months, and quarters.

2. I_FACTORYCALWORKINGDAYSPERYR (S/4HANA CDS View)

This predelivered CDS view stores factory calendar data, including:

  • Yearly working days per month, encoded as strings of 1 s (working days) and 0s (non-working days).

  • A FactoryCalendar column to differentiate regional calendars (e.g., Germany uses code 01).

  • Prerequisite: Replicate this CDS view into Datasphere via a replication flow.

CDS data image 2_Date and Factory Calendar Data

A table with columns like FactoryCalendarYearMonth01WorkingDaysString (e.g., "1111100...") etc.

Building the Unified Calendar View

Objective

Combine the two datasets to create a calendar with the following columns:

  1. Date (from M_TIME_DIMENSION)

  2. Year

  3. Day Name (e.g., Monday)

  4. Month Name (e.g., January)

  5. Working Days in Year (total working days per year)

  6. Working Day (1 or 0 indicating if the date is a working day)


Watch the recording of our webinar! 

Webinar Recording SAP Datasphere Insights and the Databricks Lakehouse Approach    View recording  

 


Step 1: Extract Basic Date Information

Start by querying M_TIME_DIMENSION to retrieve the first four columns. Use HANA’s built-in functions DAYNAME, MONTHNAME and INITCAP to format day and month names:

Key HANA Functions Explained

  • DAYNAME(date): Extracts the name of the day (e.g., "MONDAY") from a date field. By default, it returns the name in uppercase.

  • MONTHNAME(date): Retrieves the name of the month (e.g., "JANUARY") from a date, also in uppercase.

  • INITCAP(text): Converts the first letter of a string to uppercase and the rest to lowercase. This is applied to DAYNAME and MONTHNAME results to format them as "Monday" or "January" for readability.

initial query - data image 3_Date and Factory Calendar Data

A table with formatted dates, years, day names, and month names.

Step 2: Extract Working Day Flags

The challenge lies in parsing the 1/0 strings from I_FACTORYCALWORKINGDAYSPERYR. For each date, extract the corresponding value from the relevant month column using SUBSTRING:

 

MonthStringPosition image 4_Date and Factory Calendar Data

A table with the data format of the working days for each month.

Example:

  • For January 7, 2025: SUBSTRING("Month01WorkingDaysString", 7, 1)

  • For February 2, 2025: SUBSTRING("Month02WorkingDaysString", 2, 1)

Key Logic:

  • Dynamically identify the month column (e.g., Month01, Month02) based on the date.

  • Use the day of the month as the substring starting position.

 

FinalQuery image 5_Date and Factory Calendar Data

A final query that dynamically combines date data with the month columns, based on the date.

 

Step 3: Combine Data with a Join

Join the two tables on Year and filter for the German factory calendar (FactoryCalendar = '01'):

Final Data Image 6_Date and Factory Calendar Data

A unified calendar showing dates, working days, and totals
(e.g., 2025-01-01 = 0 [non-working], 2025-01-02 = 1 [working]).

Date and Factory Calendar Data - Our Conclusion

By combining M_TIME_DIMENSION with factory calendar data, we’ve created a dataset that:

  • Enriches date dimensions with working/non-working day flags.

  • Simplifies reporting for region-specific business models (e.g., production planning in Germany).

  • Leverages SQL flexibility to parse compressed string patterns into usable data.

Looking ahead, this unified calendar view opens the door to further practical enhancements like tracking sales days in a quarter, in order to compare revenue on actual sales days rather than calendar days, or supplementing fiscal reporting with year-specific period logic.

Do you have questions about SAP Datasphere? Are you trying to build up the necessary know-how in your department or do you need support with a specific issue? Please do not hesitate to contact us. We look forward to exchanging ideas with you! 

Learn more about  SAP Datasphere

avatar

Fotios

Fotios Vlantis has been in the SAP world as an ERP consultant in Greece since 2021. He is currently working as a SAP BW/BI consultant with his special focus being on SAP BW/4HANA. As a former javelin throw athlete, he likes to play sports, read and travel.

Got a question about this blog?
Ask Fotios

Combining Date and Factory Calendar Data in SAP Datasphere
5:27

Blog - NextLytics AG 

Welcome to our blog. In this section we regularly report on news and background information on topics such as SAP Business Intelligence (BI), SAP Dashboarding with Lumira Designer or SAP Analytics Cloud, Machine Learning with SAP BW, Data Science and Planning with SAP Business Planning and Consolidation (BPC), SAP Integrated Planning (IP) and SAC Planning and much more.

Subscribe to our newsletter

Related Posts

Recent Posts