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

Current Month V Previous Month

Hello,

I need some help with a query and any help would be greatly appreciated.  Trying to show current month v previous month as calculations and finding it difficult.  Table 1 I have main numbers and table 2 I am trying to show the difference and don't know where I am going wrong.

Table 1

Table 1.PNG

Table 2

Table 2.PNG

Query in expression is sum({<[Reporting Month]={">=$(=monthstart(today()))"} >} ['MI Requirement Volumes'])-sum({<[Reporting Month]={">=$(=monthstart(today(),-12))"} >} ['MI Requirement Volumes'])

Regards

Mohi

1 Solution

Accepted Solutions
sunny_talwar

Here is one option

Sum(['MI Requirement Volumes'])-Before(Sum(['MI Requirement Volumes']))

Will work on the AsOfTable Method at a later time and will respond back

Capture.PNG

View solution in original post

16 Replies
sunny_talwar

You will either have to use Missing Manual - Before() and After() or use The As-Of Table

vinieme12
Champion III
Champion III

TRY

sum({<[Reporting Month]={">=$(=monthstart(today()))"} >} ['MI Requirement Volumes'])-sum({<[Reporting Month]={">=$(=monthstart(addmonths(today(),-1)))"} >} ['MI Requirement Volumes'])

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
mohiahmed
Contributor III
Contributor III
Author

Thanks for the Vineeth, however I only get attached result now.Table 3.PNG

sunny_talwar

I have feeling it is not going to work vinieme12‌ because Date is one of the dimension. So this would show two columns, 1) for 01/01/2016 and another one for 01/01/2015 and will never put them in one column unless we use Before.

mohiahmed
Contributor III
Contributor III
Author

Thanks for that Sunny.Tying to get my head round this Sunny bit finding it difficult. Need to do more reading around it.

sunny_talwar

If you are able to share a sample, we might be able to help you better here

mohiahmed
Contributor III
Contributor III
Author


Hi Sunny, this is my load script

 

SQL

SELECT `Calculation Type`,
Customer,
`Customer System ID`,
`First Period End Date`,
`FM Description`,
`FM ID`,
`FM Type`,
Frequency,
`GAG Indicator`,
`Group ID`,
Model,
`Number of Text Components`,
`Number of Tick Components`,
`Number of Work Items per Annum`,
`Post GAG TtC DG`,
Region,
`Relationship Owner`,
`Reporting Month`,
SBU,
Team,
Type
FROM `353_Stock`
WHERE ((([353_Stock].SBU) Not In ('BA&SF')));

sunny_talwar

When I said sample, I meant your qvw file and not your script my friend. This script is not very helpful for me as I cannot run this and create the same visual like yours

mohiahmed
Contributor III
Contributor III
Author

Aha, ok sorry matey;  Let me send it over.