Skip to Content
Technical Articles
Author's profile photo Daniel Davis

SAP Analytics Cloud – Chop Up Your Dates Into Useful Parts

Recently A customer asked me where the MONTH() or YEAR() functions were in SAP Analytics Cloud (SAC), just like those in Microsoft Excel. These Excel functions allow users to return parts of a date so, for example, you can display your date by Week or by Quarter. In Excel we have the NOW() function that returns the date and time. See the following example:

We have the =now() function in B4 that returns the Date and Time but if we want to get ‘bits’ out of this we need additional functions. In E3, E4 & E5 we have functions that return the Year, the Month and the Week – in this case 2019, 12 and 50. In SAP Analytics Cloud we might want to do the same thing however there are no similar functions within SAC… or are there?

While we don’t have functions to do this we do have “properties” so let’s now look at the following scenario in SAP Analytics Cloud. I have dimension of type Date [Test v3:Date] and I want to see it as a Week Number or Month or Day or some other part, how do I chop it up? Easy, just create your chart as normal and instead of adding Date as the Dimension you create a new Calculated Dimension instead.

Select Calculated Dimension as the calculation type, name your new calculation and then add the following formula… Start with the Date Dimension name then type a full stop (point) then use the following key combination “Crtl+Spacebar” and this brings up the magic:

You can now define a Calculated Dimension for Month, Year, Quarter, Day even Day Name so a chart could them give you Sales by Day Name [d/”Test v3″:Date].[p/DAYNAME] even though the original data source only contains a date. There is a slight catch in that all Calculated Dimensions are returned as strings, this means that the daynames for example sort as strings not dates…

However a quick Custom Sort and away you go…

So now you know, simple ways to enhance your date data using Dimension Properties…. Happy Dashboarding!

Daniel.

Assigned tags

      6 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Javier Rodriguez
      Javier Rodriguez

      Thank you Daniel for this amazing post!!! I was lost trying to find the date formulas!!

      thanks again!

       

      Author's profile photo mayur tagai
      mayur tagai

      This is good. We struggle in our project for these small calculations in SAC and ultimately had to do it in back end as specific columns (which our back end team never liked 🙂 )

      Thanks for you blog we can use the above in SAC directly.  Thanks again.

      Author's profile photo PAVAN PVND
      PAVAN PVND

      Hi Daniel,

      I don't see create calculated dimension in my designer builder and also no hierarchy option seen for date dimension. My SAC version is 2020.14.11. Do i need to update my version or please let me know how can i see these options in my designer builder.

      Thanks You.

       

       

      Author's profile photo Roopa Puranik
      Roopa Puranik

      Hi Daniel,

      I am trying to pull the data from salesforce into SAC and I see that the date column comes in as a generic type and there is no way I can change that to a date type. I want to be able to parse this date into YYYY and MM but unable to do so. What you suggested can only be done on a date dimension right?

      If I do a "ctrl+spacebar" I only get ID and Descr options and not Year and Month options like in your screenshot. I know probably this will not work on Dimension type but just want to confirm. 

      Thank you

      Roopa

      Author's profile photo Daniel Davis
      Daniel Davis
      Blog Post Author

      What is the data format of the file you are importing - Excel? CSV? could you edit the interim file to turn the data into dates? You are correct that you can only chop a date into date parts but maybe in the modeller you could make a date column from the data you have?

      Author's profile photo Roopa Puranik
      Roopa Puranik

      I am retrieving the data directly from Salesforce report in SAC. The column is date type in Salesforce but comes in as Generic in the model. In SAC there is no option for me to change the type ad that's why I was asking about this in this post. We tried using SPLIT function and that seems to work for now. Thank you.