12 Replies Latest reply on Apr 19, 2018 12:37 PM by bhargavi chittibomma

# Calculate number of days in quarter based on today date

Hi,

I am trying to calculate number of days in quarter based on today's date

Ex:

if ([Current Quarter])="1" then "90"

elseif ([Current Quarter])="2" then "91"

elseif ([Current Quarter])="3" then "92"

else "94"end

this helps me in showing current quarter number of days. But this in string format.

My requirement is to divide number of days in current quarter based on today() date.

Can any one help me on this..?

Thanks

• ###### 1. Re: Calculate number of days in quarter based on today date

Take 90, 91, etc., out of quotes.  Just set the value to the numeric value.  Your calc will change to a numeric calc, and you can do math with it.

• ###### 2. Re: Calculate number of days in quarter based on today date

If that calc is already being used elsewhere and in those other places it expects a string, and changing the data type of the calc will mess up a lot of other things, then to do math with the string value do INT([Quarter calc]) where you need to do math with it.

• ###### 3. Re: Calculate number of days in quarter based on today date

I tried that but its showing different numbers

• ###### 4. Re: Calculate number of days in quarter based on today date

I think this should work all the time:

DateDiff in days between 1st day of current quarter and 1st day in following quarter:

DATEDIFF('day'

,DATETRUNC('quarter',TODAY()) //you can use a date field in place of TODAY() if you want

,DATEADD('quarter',1,DATETRUNC('quarter',TODAY())) //you can use a date field in place of TODAY() if you want

)

• ###### 6. Re: Calculate number of days in quarter based on today date

The below is what I am seeing when i use your formula

• ###### 7. Re: Calculate number of days in quarter based on today date

It will return an integer which probably defaults to be used as a Measure.

Please convert it to a Dimension.

• ###### 8. Re: Calculate number of days in quarter based on today date

Uploaded sample work book please help me with  quarter sales filed where in that 91 should be dynamic . should count number of days in current quarter

• ###### 9. Re: Calculate number of days in quarter based on today date

Awesome thanks for the help

it is working.. I thought that it wouldn't work because its a dimension but it did worked after I converted it to dimension

Thanks again!!

• ###### 10. Re: Calculate number of days in quarter based on today date

Are you all set then?  Should we mark Mark's reply as the correct answer?

• ###### 11. Re: Calculate number of days in quarter based on today date

Yes we can do that..

Thanks again for the help both of you

• ###### 12. Re: Calculate number of days in quarter based on today date

Just want to point out another way you can get that quarter value.  Instead of the case statement, do this:

datepart('quarter', today())

It's much cleaner.

• ###### 13. Re: Calculate number of days in quarter based on today date

Ohh ok thanks