Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

IF statement with IF conditions?

I made it to complicated. So let me try this:

If(MONTH(Today(1)) = 'Jan',

        IF(Year(OrderingPrescriber_RevenueDate) = (Year(Yearstart( Today( ) ))-2)

            ,Year(Today(1))-2

            ,Year(Today(1))-1)

        ,

        IF(Year(OrderingPrescriber_RevenueDate) = (Year(Yearstart( Today( ) ))-1)

            ,'STLY'

            ,'YTD'))

So if the current month is Jan I want to have it display 2013 and 2014 but if the current month is not Jan, we will consider it the current years data and we want it to display STLY and YTD.

4 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Shouldn't the second IF test be something like this (pseudo code) ?:

:

IF ((Year(OrderDate) = Year(Today()) -1) and (Month(OrderDate) = 12), 1, 0) , ...

cspencer3
Creator II
Creator II

I am a little bit confused on exactly what you are doing, but you can also use the InYearToDate() function as well to determine if a date is In the year to date. If you pass the function a -1, it will tell you if the date was in Last year's year to date (using the current date). I am not sure if that will help you but wanted to throw it out there.

Colin-Albert

This post might help with calculating YTD

http://community.qlik.com/message/469066

Not applicable
Author

I made it a bit complicated to understand. I redid the original post. Could you please take a look?