Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
AnkitaC
Contributor II
Contributor II

how to calculate previous year sales till current year same month

how to calculate previous year sales till current year same month when only monthtoyear field is available date field is not available in table .

like calculate 

jan-22 to jul-22 sales 

and previous year 

jan-21 to jul -22 sales without using date field only monthyear like jan2022 type field is available.

Labels (1)
1 Solution

Accepted Solutions
edwin
Master II
Master II

4 Replies
edwin
Master II
Master II

there are at least two ways:

save current month in a variable - vMonth,
vYearStart = in your set analysis, this is your year to month
{<DateField={">=$(=yearstart(vMonth))<=$(vMonth)"}>}

prev year to month, just addyears -1:

{<DateField={">=$(=addyears(yearstart(vMonth),-1))<=$(addyears(vMonth,-1))"}>}

 

to make this faster, you can create 4 variables: current month, 1st day of the current year, prior year month, 1st date of prior year:
vMonth

=yearstart(vMonth)

=addyears(vMonth,-1)

=addyears(yearstart(vMonth),-1)

edwin
Master II
Master II

2nd way is to build a bridge that associates the current month with all the dates from YTD and prior YTD.

this is useful when you have huge volumes of data and you dont want your UI to have to do the calculation.

 

AnkitaC
Contributor II
Contributor II
Author

Thank you so much

edwin
Master II
Master II

yw