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

Announcements
Share your agentic AI experience, learn from others, and earn a new badge: Put Agentic AI to Work
cancel
Showing results for 
Search instead for 
Did you mean: 
Karahs
Partner - Creator
Partner - Creator

Variance between two Months

Hello everyone,

               I have a pivot table in which there are month columns ie. April-March.I want to calculate variance between the two selected months.

Eg. If i select April and March i should be getting the vairance between them in the next column called variance in a pivot table.

Thanks & Regards,

Kshitija

12 Replies
sunny_talwar
MVP
MVP

Would you be able to share few rows of data to replicate what you have in the chart?

Karahs
Partner - Creator
Partner - Creator
Author

Data attached in the below link:

Variance between months‌

lydiablack
Partner - Contributor
Partner - Contributor

I find doing the work in the load script makes for the most flexible and accurate variance info at grain level

Assumes monthly level data input (syntax will be far from perfect), same concept for any time frames.

Join original table to itself where month is 1 prior

InputTable:

Load Account

        ,MonthEndDate

        ,amount

FROm inputsource;

//make an alias version to join 'real' month to prior month

NoConcatenate

PriorMonthTable

Load Account

        ,Year(MonthEndDate)*12 + Month(MonthEndDate) -1 as YYYYMMInt

       ,amount as PriorMonthAmount

RESIDENT InputTable;

FinalTable:

Load *

        ,amount - PriorMonthAmount as MonthlyVarianceAmount;

Load *

        ,Year(MonthEndDate)*12 + Month(MonthEndDate) as YYYYMMInt

RESIDENT InputTable

LEFT JOIN (InputTable)

Load Account

        ,YYYYMMint

        ,PriorMonthAmount

RESIDENT PriorMonthTable;

DROP TABLES,  InputTable, PriorMonthTable;

DROP FIELD YYYYMMInt;

Hope it helps