Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
nancybricenoa
Contributor
Contributor

Values for current month and last Month in the same table

Hello.

I have a table with values for current month (that it is a month selected by user in QV and in the same table I have to show the values for month before to selected.

I have a table with all Dates and Date_before like this:

Date_ExtractionFecha_AntOrder
201910312019093010
20190930201908319
20190831201907318

 

And the Date:Extraction is match with file with values.

So, If I select Sep-19 in the table I need to show Sum(value) for Aug and sum(value) for Sep.

Any help?

Thanks

Nancy

Labels (1)
3 Replies
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

Try this:

MC.PNG

Script:

Raw:  //Replace this with your production table
load * inline [
Date_Extraction,Fecha_Ant,Order
20191031,20190930,10
20190930,20190831,9
20190831,20190731,8
];

Data:
load *,
MONTH(Date_Extraction)&'-'&YEAR(Date_Extraction) as YearMonth,MONTH(Date_Extraction)as Month;
load Date#(Date_Extraction,'YYYYMMDD')AS Date_Extraction,Date#(Fecha_Ant,'YYYYMMDD')as Fecha_Ant,Order
resident Raw;
drop table Raw;

 

Expression:

Sum(Order)+
Sum({<Month={"$(=Month(Date(AddMonths(max(Date_Extraction),-1),'YYYYMMDD')))"},YearMonth=>}Order)

 

Thanks and regards,

Arthur Fong

nancybricenoa
Contributor
Contributor
Author

Hi!

thanks for your reply but, I need to sum (value) for last month and in anothe column sum(value) for this month. also I have another restriction .

currently my expression is:

=sum(IF(Variable='AR', Valor,0))/1000

Here I need to indicate that this sum mus be showed in a colum for date selected and another colum with valor for dete before to selected one

Thanks!

Brett_Bleess
Former Employee
Former Employee

Here are a couple of Design Blog posts that coincide with where Arthur was headed with things that should help:

https://community.qlik.com/t5/Qlik-Design-Blog/A-Primer-on-Set-Analysis/ba-p/1468344

https://community.qlik.com/t5/Qlik-Design-Blog/Year-over-Year-Comparisons/ba-p/1462927

The latter is a year over year, but figured it should be able to be adjusted to month...  That is the reason I grabbed it, sorry if it is of no help.  In the first link, there are some additional Blog links at the bottom of that one to related set analysis topics, just FYI.

Also including Help link on Set Analysis too:

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/ChartFunctions/...

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.