Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
microwin88x
Creator III
Creator III

Get Last Date's value for Each Product

Hello,

I have the following table:

ProductYearMonthPeriodSalesArea
Product12015January201501484.122134
Product12015February201502484.12253
Product12015March201503484.1246
Product12015April201504484.12215
Product22015May2015051888.07463
Product22015June2015061888.0712
Product22015July2015071888.07261
Product42015August2015081482.622376
Product42015September2015091482.62262
Product42015October2015101482.62124
Product52015November2015111788.2258
Product52015December2015121788.22456
Product52016January2016011788.22589
Product52016February2016021788.225634
Product52016March201603--
Product62016April201604829.063732
Product62016May201605829.06234
Product62016June201606756.4424
Product62016July201607756.44567
Product62016August201608756.4476
Product72016September201609756.44126
Product72016October2016101800.32567
Product72016November201611--
Product82016December2016121800.324563
Product82017January201701472.023454
Product82017February201702472.027457
Product92017March201703472.02243
Product92017April201704472.02123
Product92017May2017051040.86523
Product102017June2017061040.862348
Product102017July2017071040.86123
Product102017August201708--
Product112017September201709907.73123
Product112017October201710907.7356
Product122017November201711907.731234
Product122017December201712907.73125

What I need is to create a table with the last date for each product with the corresponding Sales and Area.

(*) Keep in mind that the last date's value could be NULL. In that case, I should bring the value before that.

Something like this:

ProductYearMonthPeriodSalesArea
Product12015April201504484.12215
Product22015July2015071888.07261
Product42015October2015101482.62124
Product52016February2016021788.225634
Product62016August201608756.4476
Product72016October2016101800.32567
Product82017February201702472.027457
Product92017May2017051040.86523
Product102017July2017071040.86123
Product112017October201710907.7356
Product122017December201712907.73125

Do you know how could I do that?

Note: I need to do it on a chart table with expressions!!!

Thank you!!!

1 Solution

Accepted Solutions
sunny_talwar

May be this

Dimension

Product

Expression

Year(Date#(Max({<Sales = {'*'}>}Period), 'YYYYMM'))

Month(Date#(Max({<Sales = {'*'}>}Period), 'YYYYMM'))

Max({<Sales = {'*'}>}Period)

FirstSortedValue({<Sales = {'*'}>}Sales, -Period)

FirstSortedValue({<Sales = {'*'}>}Area, -Period)

View solution in original post

3 Replies
sunny_talwar

What all are your dimensions and what all are the expression? I am assuming Product is the only dimension and rest all as expression?

microwin88x
Creator III
Creator III
Author

Yes, that's it.

Anyway, in the end I only need to show:

Product | Sales | Area

With the corresponding last date.

sunny_talwar

May be this

Dimension

Product

Expression

Year(Date#(Max({<Sales = {'*'}>}Period), 'YYYYMM'))

Month(Date#(Max({<Sales = {'*'}>}Period), 'YYYYMM'))

Max({<Sales = {'*'}>}Period)

FirstSortedValue({<Sales = {'*'}>}Sales, -Period)

FirstSortedValue({<Sales = {'*'}>}Area, -Period)