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

Calculate MTD from YTD values

I have all values in YTD for  every month ,i.e . Jan YTD 2022 include data from 01/01/2022 to 31/01/2022

 feb YTD include data from 01/01/2022 to 28/02/2022 and mar include data from 01/01/2022 to 31/03/2022

priyanka08_0-1652331166887.png

but need to represent  this Line chart MTD data where month -year i.e. Jan-21 is x axis 

priyanka08_1-1652331337531.png

In order to represent in textbox  ,I subtract current month YTD to last month YTD for example for

 Feb MTD= YTD feb- YTD Jan

i.e. 16-10= 6

I am facing difficulty to implement the same in line chart

 

Labels (3)
1 Reply
ZouhairLahlou
Contributor II
Contributor II

Hi Priyanka08, 

I would prepare my data in the script in order to have it ready to be plotted. To substract current month to the previous one, i would order my table by Month Asc then use PREVIOUS(). Here's a sample : 

YTD : 
Load * Inline
[ MONTH, YTD
1, 100
2, 150
3, 340
4, 500
5, 600
6, 750
7, 965
8, 1000
9, 1145
10, 1647
11, 1800
12, 2000];




MTD :
NoConcatenate
Load *,
if(isnull(Previous(YTD)), YTD,YTD - Previous(YTD)) as MTD
Resident YTD;

DROP Table YTD;


 

Regards, 

Zouhair