Skip to Content
0

How to model last 10 working days using incremental counter in HANA Graphical Calculation View?

May 12 at 01:52 PM

61

avatar image
Former Member

Hi All,

One of my requirement requires me to get a list of days for last 10 working days(working days calendar been provided by Business),

My Approach: The way I was trying to achieve by creating an incremental counter starting from the current day but I am unable to model it in the graphical calculation view, any suggestion is welcome, below screenshot to explain the logic.

Note: If it is not possible to achieve the same in Graphical calculation view, can someone help me with the code for creating the same in SQL scripted view?

Thanks in advance for any suggestion.

Regards,

Abhi

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

ANIRUDDHA SHINDE May 12 at 04:49 PM
0

You have to use advanced sql , with partition by Year and Order By Date

SUM(WORKING_DAY) OVER (PARTITION BY YEAR ORDER BY DATE DESC) RunningDay

I wrote SQL which works well with M_TIME_DIMENSION View generated in SAP HANA Modeler

SELECT SUM(WORKING_DAY) OVER (PARTITION BY YEAR ORDER BY DATE_SQL DESC) RunningDay ,* FROM ( SELECT CASE WHEN DAY_OF_WEEK IN ('06','05') THEN 0 ELSE 1 END WORKING_DAY, * FROM "_SYS_BI".M_TIME_DIMENSION WHERE DATE_SAP <='20180513' ORDER BY DATE_SAP DESC ) ORDER BY DATE_SAP DESC



Share
10 |10000 characters needed characters left characters exceeded