Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Now accepting applications for the Qlik Luminary and Partner Ambassador Programs: Apply by July 6!
cancel
Showing results for 
Search instead for 
Did you mean: 
amita1621
Contributor III
Contributor III

Current Year Qtr and previous year with Qtr

I have a Period of format '4q 2017' and i want to go to '3q 2017' . by maxstring(period) i get '4q 2017' but how should i reach to '3q 2017'.

I tried maxstring(period)-1 but it doesnt work.


Any solution on this??

Labels (1)
8 Replies
tresB
Champion III
Champion III

How did you create this field in the script? Could you post that statement?

amita1621
Contributor III
Contributor III
Author

I textbox i wrote

=MaxString(Period)

which provided output as 4Q 2017

for secondtextbox i wrote

=MaxString(Period)-1

which gives blank result

tresB
Champion III
Champion III

Thanks for the information. However, that didn't answer my query above. Could you post your sample qvw? You have to understand how maxstring() works; what the field type you are applying this expression to get the expected output. If you want one quarter back value by simply subtracting 1, then your field has to be created in the script accordingly; and that is probably a dual field and not just as a string. If you can share your sample app, we may help you suggesting a solution fits for your case.

amita1621
Contributor III
Contributor III
Author

Hi,

PFA the sample Qv file.

tresB
Champion III
Champion III

Yours is text field. Ideally this should have been created in the script as a dual field. However, to deal with this in the UI there would be many ways like using complex if..then..else along with string functions. I used another way of parsing the date and then to apply date functions..

=Ceil(Month(AddMonths(MakeDate(Right(Period,4),left(Period,1)*3),-3))/3) &'Q ' & Year(AddMonths(MakeDate(Right(Period,4),left(Period,1)*3),-3))

amita1621
Contributor III
Contributor III
Author

This doesnt work in my data . Only Q is shown as result. and its working in the sample data provided

tresB
Champion III
Champion III

Dear Amita,

That mostly like means, your sample data is not really representative sample of your actual data. And without knowing that (how your actual data is), it would be very hard for us to keep guessing and suggesting a probable solution. I would rather suggest you to provide more information about your data, or get the logic what I suggested above and try to solve yourself from there onward.

amita1621
Contributor III
Contributor III
Author

Thanks