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

I've 3 Years data (2013,2014,2015). If i select 10-Aug-2015 date it has to displays data from 9-Aug-2014 to 10-Aug-2015? How to achieve this?

Hi Community,

          

               I've 3 Years data (2013,2014,2015). If i select 10-Aug-2015 date it has to displays data from 9-Aug-2014  to 10-Aug-2015? How to achieve this?

3 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Create a straight table with the date as the dimension. Add an expression of the form:

=Sum({<datefield = {">=$(=AddYears(Max(datefield), -1)) <=$(=Date(Max(datefield)))"}>} metricfield)

Replace datefield and metricfield with the correct fieldnames for your date and metric fields.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
MK_QSL
MVP
MVP

SUM({$<YourDateField = {">=$(=Date(AddYears(Max(YourDateField)-1,-1))<=$(=Date(Max(YourDateField)))"}>}YourFieldName)

EDITED:

SUM({$<

     InvoiceMonth = ,

     InvoiceYear =,

     InvoiceWeek=,

     InvoiceQuarter=,

     InvoiceDate = {">=$(=Date(AddYears(Max(InvoiceDate)-1,-1)))<=$(=Date(Max(InvoiceDate)))"}>}Sales)

Kushal_Chawda

If your Date field format is 'DD/MM/YYY'

=sum({<Date ={">=$(=date(addyears(max(Date),-1),'DD/MM/YYYY'))<=$(=date(max(Date),'DD/MM/YYYY'))"},Year=,Month=>}Amount)

Change the Date format in your expression as per the what date format you have