Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If..THEN..ELSE - Date and Quarter

Hi All,

Trying to implement the following logic in Qlikview

If date = 1 quarter from current quarter then [type] = "A"

If date = 2,3,4 quarters from current quarter then [type] = "B"

If date > 5 quarters from current quarter then [type] = "C"

Here "date" format is "dd/mm/yyyy" and "current quarter"

format is "2017-Q1"

Can you please advise on how to create this calculation ?

Thanks

7 Replies
sunny_talwar

May be this:

If(QuarterStart(Date) = QuarterStart(Today()),

     If(Day(Date) = 1, 'A','

     If(Day(Date) <= 4, 'B', 'C')))

Not applicable
Author

Sorry this did not work.

Have issue with the format conversions.

sunny_talwar

Date format you mean? May be try this:

If(QuarterStart(Date#(Date, 'DD/MM/YYYY')) = QuarterStart(Today()),

    If(Day(Date#(Date, 'DD/MM/YYYY')) = 1, 'A','

    If(Day(Date#(Date, 'DD/MM/YYYY')) <= 4, 'B', 'C')))

Not applicable
Author

Thanks.

For today() I have a field of the format "2014-Q2".

How can I substitute this in today () ?

This part is not working

sunny_talwar

Substitute today with a field? Why would you do that?

Not applicable
Author

I have a filter and data from that is to be compared

sunny_talwar

Would you be able to share a sample as I am not sure I understand what you have and what you are hoping to get out of it