Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to calculate the data for month

I have table contains the fields like
company,Year,Months,Profit the values are like
infosys,2007-06-30,12,24,000

wipro,2007-06-30,18,56,000

ABC,2008-06-30,17,29000

tcs,2009-06-30,6,60000


in wipro i have 18 months it means financial year start from 2006-01-01
if i select the company wipro,and year 2006,it will show the profit upto
that year.i.e.,12 months data. dont show the remaining 6 month data.so
that only i asked to calculate the one month data...

8 Replies
john_duffy
Partner - Creator III
Partner - Creator III

Hello.

If you use the MonthStart command you can create a Year_Start field. This will give you the date range for each record. Then create a Select_Year field containing all possible Years. Do not link this table to your main table. You can then use the combination of the Year_Start and Select_Year with if statement(s) in your expression to return the desired results.

For example:

Load scripts:

Test_Table_Temp:
LOAD * INLINE [
COMPANY,YEAR,MONTHS,PROFIT
wipro,2007-06-30,18,56,000
ABC,2008-06-30,17,29000
tcs,2009-06-30,6,60000
];

Test_Table:
Load
COMPANY
,YEAR
,MONTHS
,MONTHSTART(YEAR,(MONTHS - 1) * -1) as YEAR_START
,PROFIT
Resident Test_Table_Temp
;

Date_Table:
Load Distinct YEAR(YEAR_START) as SELECT_YEAR
Resident Test_Table
;

Drop Table Test_Table_Temp ;

Expression:

Sum (If (YEAR(YEAR_START) = SELECT_YEAR,PROFIT,NULL()))

Not applicable
Author

Hi

I need data as monthwise....

if i want to show the data for particular month how can i show this...

Not applicable
Author

Hi all,

i m going to calculate the year like

year(Addmonths(year,-months)) as year

it will not give the current year.

if i take year(year) as year

It wont give the previous year like 2006...

but i need both the years...

how can i do it....

john_duffy
Partner - Creator III
Partner - Creator III

Hello.

Can you post a sample application using inline load. Also, based on your input records in the inline load, describe your desired result.

Not applicable
Author

hi.

Here i give the sample code.

i m going to calculate the year as year(Addmonths(year,-Months)) due to my requirement...

if i do like this i got the year like 2005,2006,2007

but i m not get the year 2008

but i need all the years like year(addmonths(year,-months)) and year(year) in the single field....

LOAD

* INLINE [

;





Not applicable
Author

code is:
LOAD * INLINE [
CompanyId, Year, Months, Profit
1, 2008/03/31, 18, "50,000"
2, 2008/03/31, 12, "25,000"
3, 2007/03/31, 12, "54,000"
4, 2006/03/31, 9, "32,000"
];

john_duffy
Partner - Creator III
Partner - Creator III

Hello.

I'm still struggling to understand the desired output. Using your inline table, can you attach a sample applicaiton and show what the desired result should look like.

For example, if 2006 is selected, I want a chart that shows:

Company Year Profit

3 2007 54,000

4 2006 32,000

Not applicable
Author

hi...

divide the profit by months.., it will give the one month profit,

also subtract the one month in the year field it will give previous month