Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Quarters in QlikView

Hi,

My calendar quarters are as follows:

Calendar Quarter          Company Quarter

1                                  3

2                                  4

3                                  1

4                                  2

I am trying to compare the company quarter to the quarter that is in the database records. I used Ceil(Month(today()) /3 for the current quarter which is the calendar quarter but the calendar current quarter is not the same as the company quarter. How do I change that?

Thanks.

1 Solution

Accepted Solutions
anbu1984
Master III
Master III

Mod(Ceil(Month(today()) /3)+2,4)


Ceil(Month(today()) /3 -- Gives Calendar quarter


Mod(1+2,4) = 3

Mod(2+2,4) = 0 -- If(Mod(Ceil(Month(today()) /3)+2,4),Mod(Ceil(Month(today()) /3)+2,4),4) returns 4

Mod(3+2,4) = 1

Mod(4+2,4) = 2


From QV Help

mod(x1 , x2)

Mathematical modula function. Both parameters must have integer values. x2 must be greater than 0. The result is the non-negative remainder of an integer division.

View solution in original post

6 Replies
anbu1984
Master III
Master III

If(Mod(Ceil(Month(today()) /3)+2,4),Mod(Ceil(Month(today()) /3)+2,4),4)

jaimeaguilar
Partner - Specialist II
Partner - Specialist II

Hi,

if you already have 1,2,3,4 as values for Calendar Quarter field, you can use either an inline table or pick function in script:

pick([Calendar Quarter], 3,4,1,2) as [Company Quarter]

regards

anbu1984
Master III
Master III

=Pick(Ceil(Month(today()) /3),3,4,1,2)

Not applicable
Author

RS:

Anorher option is a mapping load,

Map_Quarter:

Mapping

LOAD * INLINE [

    Quarter, CompanyQuarter

    1, 3

    2, 4

    3, 1

    4, 2

];

Load

Quarter,

ApplyMap('Map_Quarter',Quarter) AS CompanyQuarter

From YourCalendar

There you will have a relation between the Calendar Quarter and Company Quarter.

Hope it helps!

Regards!

Not applicable
Author

Can you please explain what Mod(Ceil(Month(today()) /3)+2,4 does?

Thank you.

anbu1984
Master III
Master III

Mod(Ceil(Month(today()) /3)+2,4)


Ceil(Month(today()) /3 -- Gives Calendar quarter


Mod(1+2,4) = 3

Mod(2+2,4) = 0 -- If(Mod(Ceil(Month(today()) /3)+2,4),Mod(Ceil(Month(today()) /3)+2,4),4) returns 4

Mod(3+2,4) = 1

Mod(4+2,4) = 2


From QV Help

mod(x1 , x2)

Mathematical modula function. Both parameters must have integer values. x2 must be greater than 0. The result is the non-negative remainder of an integer division.