Hello Ramana,
in general the formula to calculate your required value is: Week for Current Date - Week for Quarter Start Date + 1
In a query statement this can look like following (you can test it with a table containing a date column by replacing the schema/table/column name):
select ( week(to_date("TEST_DATE")) - week(to_date(year("TEST_DATE") || (case month("TEST_DATE") when 1 then '01' when 2 then '01' when 3 then '01' when 4 then '04' when 5 then '04' when 6 then '04' when 7 then '07' when 8 then '07' when 9 then '07' when 10 then '10' when 11 then '10' when 12 then '10' end) || '01') ) + 1) as month_in_qrt from "DEMO"."TEST_DATE";
Now what options to you have to get your desired result in a graphical calculation view?
Since HANA SPS10 it is possible to use SQL expressions in an expression for a calculated column. But at least on my system it didn't work, because functions like "week" and "month" are not supported up to now (I didn't find a concrete list of supported or not supported functions for that usage , but I assume that that functions are not supported up to now and I didn't make a mistake).
But you have an option to reach your goal by using the same formula in a different way. The key point is just, how to determine the week for the quarter start date for your date. Here you can use entries of time dimension table "_SYS_BI"."M_TIME_DIMENSION". This table "can contain" for each day the week information (in column "WEEK"). That the table is filled you have to generate the time data in the required form (Creating Information Views - Generate Time Data - SAP HANA Modeling Guide - SAP Library).
When the data in the time dimension table is available you can determine the week for the date in your date column. That is the easy part. To be able to determine the date for the quarter start date you have to construct the quarter start date out of the date in your date column. This can be done by using the "component" function (Date Functions - SAP HANA Modeling Guide - SAP Library) to extract the year and month information of your date. For the extracted month you have to determine the month of the quarter start date using the "case" function (when the month is 1, 2 or 3 then the quarter start month is 1, when the month is 4, 5 or 6 then the quarter start date is 4 ...). With the extracted year information and the determined quarter start month the quarter start date can be constructed by using "01" as day. With the constructed date the week can than be determined from the time dimension table.
With both week information the above formula can be applied then.
A simple test view looks like following.
The expression to calculate the quarter start date looks like following.
The calculation of the week in the month looks like following.
The result for some random data (incl. the calculated intermediate results) looks like following.
Best Regards,
Florian