Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Comparing Last month and Current Month values Through Straight Table

Hi Qliksupport Team,

I am trying to compare last month figures with current month figures and able to achieve it using the below formula...

Straight_Table_Last_Curr_Month.png

Month(SNAPSHOT_PERIOD) as Month,

     Date(MonthStart(SNAPSHOT_PERIOD), 'MMM-YYYY') as [Month Year],

     Year(SNAPSHOT_PERIOD) as Year

From a table...

&

set vMaxMonthYear = =Date(max([Month Year]), 'MMM-YYYY');

set vPriorMonthYear = =Date(addmonths(max([Month Year]), -1), 'MMM-YYYY');

let vMaxDate  = '=max(Date)';

let vMaxDay   = '=day(vMaxDate)';

let vMaxMonth  = '=month(vMaxDate)';

let vMaxYear  = '=Year(vMaxDate)';

let vPriorMonth  = '=month(addmonths(max(Date),-1))';

let vPriorYear  = '=vMaxYear-1';

let vPriorYearDate = '=date(addyears(max(Date),-1),' & chr(39) & 'DD MMM YYYY' & chr(39) & ')';

Created above variables...

Last month expression ::

='Last Month Fact_Resrv_1

$(vPriorMonthYear)'

Current Month Expression ::

Sum({<[Month Year]={'$(vMaxMonthYear)'},Year=,Month=,Date=>}CHNL_FACT_RESRV_1)

But however, when I use MonthYear as dimension in the same straight table, the result is as below...

Straight_Table_Last_Curr_With_Month.png

Is it possible to display same as first image even after adding MonthYear as dimension in straight table...?

If possible in any other chart(pivot table), please give the formulas for current & Previous month expressions...

1 Reply
sunny_talwar

There is few ways to do this

Use The As-Of Table

or use the

Missing Manual - Above() and Below()