# App Development

Announcements
QlikWorld 2022, LIVE in Denver CO., May 16-19, 2022. REGISTER NOW TO RECEIVE EARLY BIRD PRICING
cancel
Showing results for
Did you mean:
Creator

## Privious Year YTD

Hi

I am struggling alot to show the Previous year YTD info in a table.

Below mentioned is my expression. Its showing the entire previous year data. But logically it has to show till August 2016.

1 Solution

Accepted Solutions
Creator
Author

I used the below expression...Its working as per my expectation .... tanq so much for all  your suggestions

=Sum({<segment=,Year={\$(vPriorYear)}, fiscal_quarter=, Month=,Date={"\$(='>='&Date(YearStart(Max(Date),-1),'MM/DD/YYYY') & '<=' & Date(AddYears(Max(Date),-1),'MM/DD/YYYY'))"}>}accessories_revenue)

10 Replies
Creator III

Create a flag for Previous Year and current year

Then use that flag in the expression

if(Month(Date_cloumn)>8,year(Date_column)&' to '&year(Date_column)+1,

if(Month(Date_cloumn)<8,year(Date_column)-1&' to '&year(Date_column),

if(Month(Date_cloumn)=8 and Date(Date_column,'DD')<=25,

year(Date_column)-1&' to '&year(Date_column),

year(Date_column)&' to '&year(Date_column)+1

))) as Fiscal_Year

Creator
Author

Hi Sibin

I already have a previous year and current year flag....

Let vlastyear=YearStart(Today(),-1);

Let vcurrentyear=YearStart(Today());

But nothing is working out

Do you have any straight forward formula which gives Prior year YTD output?

Creator III

Try this

Create Month Column, values should be 1,2,3 etc.

if it already available, you can use the existing column or you can create using

Date(Date_Column,'MM') as Month_Column

Create variable vMonth_value

Definition give it as 8

Sum({<Year={\$(vPriorYear)}, fiscal_quarter=, Month=, [Date]=,

Month_Column={"<=\$(=vMonth_value)"},

Contributor III

Hi Surya,

Can you please try with the below expression

Sum({<Year={\$(vPriorYear)}, fiscal_quarter=, Month=, [Date]=, Month={'<=\$(=max({<Year={\$(=max(Year))}>}accessories_revenue)

If it is not working, please let me know. In this expression instead of using the variable you can use

Year={\$(=max(Year)-1)}.

Thanks

Gopi

Creator
Author

Hi Gopi

I think there is some issue in the below part

Month={'<=\$(=max({<Year={\$(=max(Year))}>}

Creator
Author

I have reformed my formula like this

Sum({<Year={\$(=max(Year)-1)},fiscal_quarter=, Month=, [Date]=, Month={'<=\$(=max({<Year={\$(=max(Year))}>}))>'}>}accessories_revenue)

Its giving null output

Creator

Try this below code:

Month=,Quarter=,WeekDay=,MonthlyWeekNumber=>}accessories_revenue)

@

Try below

Sum({<Year={\$(=max(Year)-1)},fiscal_quarter=, Month=, [Date]=,Month={"<=\$(=max(Month))"}>}accessories_revenue)

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Creator
Author

I used the below expression...Its working as per my expectation .... tanq so much for all  your suggestions

=Sum({<segment=,Year={\$(vPriorYear)}, fiscal_quarter=, Month=,Date={"\$(='>='&Date(YearStart(Max(Date),-1),'MM/DD/YYYY') & '<=' & Date(AddYears(Max(Date),-1),'MM/DD/YYYY'))"}>}accessories_revenue)

Tags
Community Browser