Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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)
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.
Thank you so much
yw