Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to calculate MonthStart to Today + LYMonthToday to MonthEnd?

For this calculation, I need the data from the current month's first day to current day, plus the data from last year of the same month and day until the end of the month. It cannot be static, meaning when the current date changes, so must the aggregation of the data sets.

For example, (December 1, 2017 - December 13, 2017) + (December 13, 2016 - December 31, 2016)

And in a week (December 1, 2017 - December 20, 2017) + (December 20, 2016 + December 31, 2016)

I currently have two variables to represent the two sets of criteria

     vTRIRCurrentMonth: '>=$(monthstart(dte))<=$(vToday())'

      vTRIRMonthLY: '>=$(vPreviousYearMonth=Today())<=$(vPreviousYearMonth=MonthEnd)'

I am not getting results when I combine in the expression for the chart.

1 Reply
Anil_Babu_Samineni

May be this?

And For Month

Sum({<DateFields= {">=$(=Date(MonthStart(Today()))) <=$(=Date(WeekEnd(Today())))"}>} Sales) + Sum({<DateFields= {">=$(=Date(AddYears(Today(),-1))) <=$(=Date(AddYears(MonthEnd(Today()),-1)))"}>} Sales)


And For week

Sum({<DateFields= {">=$(=Date(MonthStart(Today()))) <=$(=Date(Today()))"}>} Sales) + Sum({<DateFields= {">=$(=Date(AddYears(WeekEnd(Today()),-1))) <=$(=Date(AddYears(MonthEnd(Today()),-1)))"}>} Sales)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful