Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
bharatkishore
Creator III
Creator III

YTD Issue

Hi All,

I have a qvd with following fields

YearMonth,

     Calendar_Year,

     Plant,

     BUEqui,

     Strategic_Flag,

     Country,

     Contract_Type,

     Part_Type,

     Fiscal_Month,

     ITM_IB,

     ITM_Consumption

and to get YTD logic i have given the below condition:

FinalTable:


LOAD*,


If(BUEqui = Previous(BUEqui) and Plant = Previous(Plant)  and Calendar_Year = Previous(Calendar_Year) , RangeSum(ITM_Consumption, Peek('YTD_Consumption')), ITM_Consumption) as YTD_Consumption


Resident QV_intermediate_temp5


order by BUEqui,Plant,YearMonth ;


DROP Table QV_intermediate_temp5;


Below image for reference:


T.PNG


If you see my YTD_cons for Jan is fine but for feb instead of 1934+6913 =8847 i am getting 176974.


Can you please help where i am doing wrong.


Attached app for reference.


Thanks,

Bharat

13 Replies
sunny_talwar

Check now

bharatkishore
Creator III
Creator III
Author

Sunny Bhai.. Thank you so much. Thanks a lot..

One last question can you please tell me why you have given these two steps:

AutoNumber(Plant&BUEqui&Strategic_Flag&Country&Contract_Type&Part_Type&ITM_IB&Calendar_Year) as Key,

     Sum(ITM_Consumption) as ITM_Consumption

why we did sum(ITM_Consumption)..

Please..Kindly wanted to know.

sunny_talwar

1) Created Key as it helped make the if condition and Order by easier... you don't have to create the Key... but then you will have to add all the fields from the Key into your if condition and Order By

2) Sum because like I mentioned before... you have multiple rows for each combination of Key making Previous function not work the way you would expect it to work

bharatkishore
Creator III
Creator III
Author

Thanks a lot Sunny Bhai. Thank you so much. I know you don't like to say these many times.. But thank you so much..