Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

OmarBenSalem
Esteemed Contributor

How to return today's quarter in set expression?

hi all ( stalwar1‌ ):

how to return today's quarter?

I was thinking about sthing like this (The syntax is for sure wrong);

sum({<Quarter={"=max(Month)=Month(Today()) "}>} Measure)



Now the question is, is my logic correct ; if so please help me correct the syntax.

and is there another way, simpler than this?

Thanks !

6 Replies

Re: How to return today's quarter in set expression?

Max(Month) will always be (most likely) end of the quarter.... for example, let's assume we were in November... Max(Month) = 12 and Month(Today()) = 11.... Not sure if this can happen, but if it does, then it might not work....

OmarBenSalem
Esteemed Contributor

Re: How to return today's quarter in set expression?

Do u have a proposition on how to do?

I mean sthing like ?

sum({<Quarter={"=(Month)=Month(Today()) "}>} Measure)


with the right syntax?

Khan_Mohammed
Honored Contributor II

Re: How to return today's quarter in set expression?

I don't know if the Quarter Flag would work for you?

In script you can use

if(InQuarterToDate(YOURDATEFIELD, today(),0), 1, 0) as CurQtrFlag,

This will always give you current quarter

Re: How to return today's quarter in set expression?

Not entirely sure why you are taking this route, but may be this

Sum({<Quarter = p({<Month = {"$(=Month(Today())"}>} Quarter)>} Measure)

OmarBenSalem
Esteemed Contributor

Re: How to return today's quarter in set expression?

Thanks ; I'm aware of such an alternative, but I was wondering if there is a possibility to do such a thing directly within the set expression

Khan_Mohammed
Honored Contributor II

Re: How to return today's quarter in set expression?

Year(Today())&'Q'&ceil(Month(Today())/3)

Store above in Variable and use the variable in your Set if you hvae correct format for year and quarter

Community Browser